System info: glib 1.2.9 on Solaris 7. Using gcc2.9.5 and posix threads.
I am having a problem using GString and was wondering if anyone had ever experienced anything similar. Specifically, the call to the function g_string_new() has problems in some situations. What happens is that g_string_new() gets into a very long loop inside the g_mem_chunk_alloc() function, and eventually crashes. g_string_new calls a series of functions to get to the g_mem_chunk_alloc() function:
-g_string_new()
-g_string_sized_new()
-g_mem_chunk_alloc() (called thru macro g_chunk_new)
There is a while loop inside g_mem_chunk_alloc() that always seems to be satisfied, and thus the long looping. Here is the condition (gmem.c line 567): while(rmem_chunk->free_atoms)
Eventually, after several minutes, inside the while loop, the call to g_tree_search (gmem.c line 578) returns NULL:
/* Determine which area this piece of memory is allocated from */
temp_area = g_tree_search (rmem_chunk->mem_tree,
(GSearchFunc) g_mem_chunk_area_search,
mem);
and the next instruction accesses the memory pointed to by temp_area (gmem.c line 594):
if (temp_area->mark) {....}
Since temp_area is NULL, and the process crashes with a segmentation fault. temp_area comes from a
This does not happen every time I call g_string_new(). In my program, it seems to happen the second time I call g_string_new() in a loop. However, when I wrote a test program calling g_string_new repeatedly, the problem did not happen. Also, in my program there are other threads in the process probably calling g_string_new() at the same time. Is g_string_new() thread safe?
If anyone has any similar exepriences or any suggestions as to what to do, that would be greatly apprecieated.
Thanks,
Edward Lin
SS8 Networks Inc.
tel(905)8895900x8224 fax(905)8899853
elin ss8 com www.ss8.com