In a multi-threaded C program I used GList functionality of GLib (https://developer.gnome.org/glib/2.35/glib-Doubly-Linked-Lists.html#g-list-append) where multiple threads created their own lists. I observed unpredictable crashes, sometimes as soon as the application loads. The stack trace shows some crash in glist_* functions some message like this:
(gdb) bt
#0 0x00007fffeb54a964 in g_slice_alloc () from /lib64/libglib-2.0.so.0
#1 0x00007fffeb52aac6 in g_list_append () from /lib64/libglib-2.0.so.0
Or messages like this:
MEMORY-ERROR: [25628]: GSlice: assertion failed: sys_page_size == 0 Aborted (core dumped)
(process:15426): GLib-ERROR (recursed) **: gmem.c:157: failed to allocate 137438953456 >bytes aborting... Aborted (core dumped)
I have reasons to believe that introduction of GList caused all this crashes. In a single threaded program, I have never seen these issues.
Is GList inherently thread-safe? If not, what I need to do?