Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » al_dtor_list is NULL, crash in al_create_timer

This thread is locked; no one can reply to it. rss feed Print
al_dtor_list is NULL, crash in al_create_timer
Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Hello guys.

I'm getting a crash in my ManyMouse program. This time I've built it with MSVS 2015 and the Allegro 5 Nuget package. It crashes on startup when I try to create a timer in al_create_timer.

Here's the backtrace :

# allegro-debug-5.2.dll!_al_mutex_lock(_AL_MUTEX * m) Line 59
# allegro-debug-5.2.dll!_al_register_destructor(_AL_DTOR_LIST * dtors, const char*
#    name , void * object, void (void *) * func) Line 166
# allegro-debug-5.2.dll!al_create_timer(double speed_secs) Line 235
# ManyMouseRawInputTest.exe!RawInputHandler::SetupWindows() Line 435
# ManyMouseRawInputTest.exe!main(int argc, char * * argv) Line 59

And here's the value of the local variables in frame 2 (al_create_timer line 235). Notice that al_dtor_list is NULL.

+		_al_dtor_list	0x00000000 <NULL>	_AL_DTOR_LIST *
		speed_secs	0.016666666666666666	double
+		timer	0x0074a230 {es={__pad=0x0074a230 {7757888, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...} } ...}	ALLEGRO_TIMER *
		timer->counter	0.00000000000000000	double
		timer->speed_secs	0.016666666666666666	double

Here's line 235 of al_create_timer :

timernu.c#SelectExpand
228 if (timer) { 229 _al_event_source_init(&timer->es); 230 timer->started = false; 231 timer->count = 0; 232 timer->speed_secs = speed_secs; 233 timer->counter = 0; 234 235 _al_register_destructor(_al_dtor_list, "timer", timer, 236 (void (*)(void *)) al_destroy_timer); 237 }

The exact same program compiled with MinGW 4.8.1 does not crash there. So it may be something to do with dlls? But I don't know what, because al_install_system is succeeding, otherwise the program would quit before it got there.

I can't get a simple test program to fail in the same way. This code works and exits with return code 0.

#SelectExpand
1#include "allegro5/allegro.h" 2 3int main(int argc, char** argv) { 4 5 if (!al_install_system(ALLEGRO_VERSION_INT, atexit)) { 6 return 1; 7 } 8 9 ALLEGRO_TIMER* timer = al_create_timer(1.0 / 60.0); 10 11 if (!timer) { 12 return 2; 13 } 14 15 16 return 0; 17}

EDIT Any idea why the same program compiled with MSVS 2015 would crash while one compiled with MinGW would work?
It shouldn't have anything to do with resources, and the fact that it is crashing inside an innocuous function like al_create_timer is a bit odd, as Allegro has been successfully initialized.

Go to: