[Gc] GC 6.8 bus error on Solaris SPARC 9

jim marshall jim.marshall at wbemsolutions.com
Wed Jan 16 22:38:08 PST 2008


Hello,
 We have a program using GC 6.8, it is running fine on Linux and Windows 
but on Solaris SPARC (9) we get a crash that occurs, we narrowed this 
down to a simple test case (attached).

Basically we are allocating a block of memory of size 41683, we then try 
to get a pointer to the last 4 bytes so we can store some data and we 
get a SIGBUS error. We've tried using "GC_MALLOC" and 
'GC_MALLOC_IGNORE_OFF_PAGE' and we get the same results (bus error).

Any thoughts on what might be going on here (e.g. what have I done wrong)?

output on "SunOS Sol9Sparc 5.9 Generic_112233-01 sun4u sparc SUNW,Ultra-30"
$ ./a.out
calling getmarkerArea
Setting size
Bus Error (core dumped)


GDB shows (line # might be off as I added the compile comments to this 
email):

Core was generated by `./a.out'.
Program terminated with signal 10, Bus error.
#0  0x000107d4 in main (argc=1, argv=0xffbffa9c) at gctest.c:37
37        *a = SIZE_ONE;

Thanks in advance

/* file: gctest.c */
#include <stdio.h>
#include <string.h>

#define USE_MUNMAP
#include "gc.h"

/*
compile as follows on Solaris with gcc
gcc -g -I<GC>/include/ -L<GC>/lib -lgc -Wl,-R <GC>/lib gctest.c

compile as follows on Linux with gcc
gcc -g -I<GC>/include/ -L<GC>/lib -lgc -Wl,-rpath=<GC>/lib gctest.c
*/

#define SIZE_ONE 1024
#define SIZE_THREE 41679

static size_t* getMarkerArea(const void *p, size_t size)
{
    char *buf = (char*)p;
    char *area = &buf[size];
    size_t *ret = (size_t*)area;
    return ret;   
}

int main(int argc, char** argv)
{
  char *p = NULL;
  size_t *a = NULL;

  GC_INIT();

  p = GC_MALLOC_ATOMIC(SIZE_THREE + sizeof(size_t));
  //  memset(p, 'x', SIZE_ONE);

  printf("calling getmarkerArea\n");
  a = getMarkerArea(p, SIZE_THREE);
  printf("Setting size\n");
  *a = SIZE_ONE;

  printf("DONE\n");
  return 0;
}






More information about the Gc mailing list