Segfault on Linux when destroying timer or event queue
EDIT: Figured this out just after posting it, classic. Problem was the shutdown function being named shutdown. This must be a reserved name?
I've got some relatively simple shutdown code:
Thread 1 "aqsu" received signal SIGSEGV, Segmentation fault.
0x00000000004a8750 in _al_list_item_data ()
#0 0x00000000004a8750 in _al_list_item_data ()
#1 0x0000000000461c50 in _al_unregister_destructor ()
#2 0x000000000046703d in al_destroy_timer ()
#3 0x0000000000406169 in shutdown () at boot.c:69
#4 0x00007ffff6259be2 in xcb_disconnect () from /lib64/libxcb.so.1
#5 0x00007ffff7543407 in XCloseDisplay () from /lib64/libX11.so.6
#6 0x00000000004a9fe7 in xglx_shutdown_system ()
#7 0x0000000000465f28 in shutdown_system_driver ()
#8 0x0000000000463314 in _al_run_exit_funcs ()
#9 0x0000000000465fa5 in al_uninstall_system ()
#10 0x00007ffff64b1b88 in __run_exit_handlers () from /lib64/libc.so.6
#11 0x00007ffff64b1bda in exit () from /lib64/libc.so.6
#12 0x00007ffff6497041 in __libc_start_main () from /lib64/libc.so.6
#13 0x0000000000405d19 in _start ()
If I put the al_destroy_event_queue first, the segfault happens within that function. I can't find any loose pointers in my code; might this be a bug?
Thread #617166. Printed from Allegro.cc
Not exactly a reserved name, but I guess it is a name clash - we can see from the stacktrace that xcb_disconnect() tries to call a function called shutdown() and accidentally calls yours instead of its own. Ideally the linker would have at least warned about clashing symbols when you built your program, but maybe it didn't?