Search code examples
segmentation-faultglib

magazine_chain_pop_head Segmentation fault at gslice.c:539


I catch a segfault that caused by calling g_slice_alloc0(160); I can call g_slice_alloc0(320), g_slice_alloc0(128), or any value except 160 without catching segfault with gdb.

I have even enabled the G_SLICE=always-malloc or G_SLICE=debug-blocks, but program behaviour doesn't change.

For assuring that problem is not double freeing, I have even ignored freeing the memory for a test.

(relevant link: https://mail.gnome.org/archives/gtk-devel-list/2010-December/msg00065.html)


Solution

  • The same answer as from the mailing list thread applies here:

    It's possible the slice allocator has bugs, but the more probable reason for those crashes is memory corruption and double-frees in the affected code. Each bug should be treated as separate ones until root-caused.

    Without seeing your code, the bug in it cannot be found. Have you run your code under valgrind to search for other memory corruption problems?