Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » Segfault on Linux when destroying timer or event queue

This thread is locked; no one can reply to it. rss feed Print
Segfault on Linux when destroying timer or event queue
dthompson
Member #5,749
April 2005
avatar

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:

#SelectExpand
1void shutdown() 2{ 3 if(s.timer) 4 al_destroy_timer(s.timer); 5 6 if(s.buffer) 7 al_destroy_bitmap(s.buffer); 8 9 if(s.disp) 10 al_destroy_display(s.disp); 11 12 if(s.queue) 13 al_destroy_event_queue(s.queue); 14}

This segfaults:

Thread 1 "aqsu" received signal SIGSEGV, Segmentation fault.
0x00000000004a8750 in _al_list_item_data ()
[...]
(gdb) where
#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?

______________________________________________________
Website | Where my website used to be
This isn't a game!

Bruce Perry
Member #270
April 2000

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?

--
Bruce "entheh" Perry [ Web site | DUMB | Set Up Us The Bomb !!! | Balls ]
Programming should be fun. That's why I hate C and C++.
The brxybrytl has you.

Go to: