Bug with GMemChunk




This piece of code fails with a segmentation fault on
Solaris 2.7/Sparc. I am using GLib 1.3.1.

#include <glib.h>

#define SIZE 4096

static GMemChunk *test = NULL;

int
main ()
{
  guint8 *test1, *test2, *test3;
  gint i;

  test = g_mem_chunk_new ("test mem chunk",
			  SIZE,
			  16, G_ALLOC_AND_FREE);
  
  test1 = g_chunk_new (guint8, test);
  test2 = g_chunk_new (guint8, test);

  for (i=0; i<SIZE; i++)
    test2[i] = 'b';

  test3 = g_chunk_new (guint8, test);
  return 0;
}

Here is the stack trace:

#0  0xff2c5518 in _malloc_unlocked ()
#1  0xff2c5314 in malloc ()
#2  0xff35a5cc in g_malloc (size=4096) at gmem.c:177
#3  0xff35ac08 in g_mem_chunk_alloc (mem_chunk=0x21a20) at gmem.c:663
#4  0x10b60 in main () at mcbirnan.c:23



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]