Primitives addon shutdown code shutting down d3d?
Edgar Reynaldo

I'm not sure what I'm doing wrong. It's probably my fault but my program is crashing in al_shutdown_primitives_addon, called from al_uninstall_system, called from atexit.

I'm using a very recent git build, with MinGW 4.8.1 and Vista.

Here's the backtrace :

#SelectExpand
1Program received signal SIGSEGV, Segmentation fault. 20x00402de0 in AssertHandler (exp=0x678671b0 <__func__.6213+193> "display", file=0x678671b8 <__func__.6213+201> "C:\\mingw\\LIBS\\A5GIT\\allegro\\src\\display.c", line=310, func=0x678673fd <__func__.35368> "al_get_display_flags") at C:\Research\RawInput\InputTest\MouseTestMain.cpp:12 312 *i = 1; 4(gdb) bt 5#0 0x00402de0 in AssertHandler (exp=0x678671b0 <__func__.6213+193> "display", file=0x678671b8 <__func__.6213+201> "C:\\mingw\\LIBS\\A5GIT\\allegro\\src\\display.c", line=310, func=0x678673fd <__func__.35368> "al_get_display_flags") at C:\Research\RawInput\InputTest\MouseTestMain.cpp:12 6#1 0x6771fa04 in al_get_display_flags (display=0x0) at C:\mingw\LIBS\A5GIT\allegro\src\display.c:310 7#2 0x67801c30 in al_destroy_index_buffer (buffer=0x2812be8) at C:\mingw\LIBS\A5GIT\allegro\addons\primitives\primitives.c:327 8#3 0x677f9c6e in destroy_display_local_data () at C:\mingw\LIBS\A5GIT\allegro\addons\primitives\prim_directx.cpp:197 9#4 0x677f9d22 in _al_shutdown_d3d_driver () at C:\mingw\LIBS\A5GIT\allegro\addons\primitives\prim_directx.cpp:222 10#5 0x67800e47 in al_shutdown_primitives_addon () at C:\mingw\LIBS\A5GIT\allegro\addons\primitives\primitives.c:62 11#6 0x677260ab in _al_run_exit_funcs () at C:\mingw\LIBS\A5GIT\allegro\src\exitfunc.c:92 12#7 0x67732ef3 in al_uninstall_system () at C:\mingw\LIBS\A5GIT\allegro\src\system.c:314 13#8 0x76201fef in msvcrt!_flushall () from C:\Windows\system32\msvcrt.dll 14#9 0x85fd4fee in ?? () 15#10 0x0022fea4 in ?? () 16#11 0x76202177 in msvcrt!_cexit () from C:\Windows\system32\msvcrt.dll 17#12 0x00000000 in ?? () 18(gdb) quit

For some reason the display is null at the point when al_get_display_flags is called.

However, this begs the question, why is the primitives shutdown code shutting down d3d?

SiegeLord

However, this begs the question, why is the primitives shutdown code shutting down d3d?

It's not, it's just shutting down the D3D driver of the primitives addon. Is this something easily reproducible?

Edgar Reynaldo

No, I can't reproduce it anymore.

Now my program is crashing somewhere else, but only in release mode. If I link to the debugging allegro monolith it doesn't crash.

I can give you the backtrace, but there are no line numbers. However, it crashes while trying to create an opengl display.

#SelectExpand
1Program received signal SIGSEGV, Segmentation fault. 2[Switching to Thread 5868.0x100c] 30x6f15611e in _al_ogl_manage_extensions () from c:\Research\RawInput\InputTest\allegro_monolith-5.1.dll 4(gdb) bt 5#0 0x6f15611e in _al_ogl_manage_extensions () from c:\Research\RawInput\InputTest\allegro_monolith-5.1.dll 6#1 0x6f15dd68 in create_display_internals () from c:\Research\RawInput\InputTest\allegro_monolith-5.1.dll 7#2 0x6f15e5a2 in wgl_create_display () from c:\Research\RawInput\InputTest\allegro_monolith-5.1.dll 8#3 0x6f0e1e38 in al_create_display () from c:\Research\RawInput\InputTest\allegro_monolith-5.1.dll 9#4 0x0040215a in ?? () 10#5 0x0040234f in ?? () 11#6 0x00402810 in ?? () 12#7 0x00402a0f in ?? () 13#8 0x00403cca in ?? () 14#9 0x00403d2f in ?? () 15#10 0x6f136783 in window_callback@16 () from c:\Research\RawInput\InputTest\allegro_monolith-5.1.dll 16#11 0x767ff8d2 in USER32!GetMessageW () from C:\Windows\system32\user32.dll 17#12 0x767ff794 in USER32!GetWindowLongW () from C:\Windows\system32\user32.dll 18#13 0x6f136670 in postpone_thread_proc () from c:\Research\RawInput\InputTest\allegro_monolith-5.1.dll 19#14 0x76800008 in USER32!PeekMessageW () from C:\Windows\system32\user32.dll 20#15 0x76800060 in USER32!DispatchMessageW () from C:\Windows\system32\user32.dll 21#16 0x6f13ee29 in d3d_display_thread_proc(void*) () from c:\Research\RawInput\InputTest\allegro_monolith-5.1.dll 22#17 0x6f0eef81 in detached_thread_func_trampoline () from c:\Research\RawInput\InputTest\allegro_monolith-5.1.dll 23#18 0x6f138ef4 in thread_proc_trampoline@4 () from c:\Research\RawInput\InputTest\allegro_monolith-5.1.dll 24#19 0x770a2cce in wcstombs_s () from C:\Windows\system32\msvcrt.dll 25#20 0x770a2deb in msvcrt!_beginthreadex () from C:\Windows\system32\msvcrt.dll 26#21 0x77554b29 in KERNEL32!BaseThreadInitThunk () from C:\Windows\system32\kernel32.dll 27#22 0x773ce1c6 in ntdll!RtlInitializeExceptionChain () from C:\Windows\system32\ntdll.dll 28#23 0x773ce199 in ntdll!RtlInitializeExceptionChain () from C:\Windows\system32\ntdll.dll 29#24 0x00000000 in ?? () 30(gdb) quit

I should say, just out of chance, I have created both a main D3D display, and each mouse pointer opens an OpenGL display (which takes way longer, and now crashes for some reason).

Thomas Fjellstrom

I suspect uninitialized variable/memory access.

Thread #615421. Printed from Allegro.cc