SDL_CreateRenderer crash

Hi all,

I was playing a little bit with the SDL2 library last night, and I hit a
problem that looks like a nasty SDL bug…

I am primarily developing on Linux, and there my code works fine, but
then I tried to port my app to Windows, using a Windows XP system
running on a VirtualBox. The code compiles fine, but whenever it tries
to call SDL_CreateRenderer, the application crashes.

I don’t post my code, because I think it is irrelevant - to be sure, I
also tested with the official code example from there:
https://wiki.libsdl.org/SDL_CreateRenderer

…and it also crashes, at the same moment (calling SDL_CreateRenderer).

This is how I compile the application (I copied the list of parameters
from the sdl-config file shipped with the library):

C:>gcc -O3 -Wall -std=gnu89 test.c -o test.exe -lmingw32
-Dmain=SDL_main -lSDL2main -lSDL2 -mwindows -Wl,–no-undefined -lm
-ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32
-loleaut32 -lshell32 -lversion -luuid -static-libgcc

The SDL lib I test with is the v2.0.3. I also tested on v2.0.2 - same
result.
The Windows XP virtual machine I am testing this on is a bare, freshly
installed Windows XP service pack 3, without any add-ons.

To avoid crashing, I pass the parameter “SDL_RENDERER_SOFTWARE”. When
using no flags, or the “SDL_RENDERER_ACCELERATED” flag, it crashes.

I presume that the crash is somehow related to the fact that SDL tries
to probe for some acceleration magic, and hangs on it… Now, how should
I proceed to be able to use accelerating on systems that have such
capabilities, and avoid crashing on systems without any powerful GPU
(basic GDI) ?

best regards,
Mateusz

Hello,

I would assume that VirtualBox is the problem here ( it might say it has
acceleration, but when SDL is trying to use it something goes wrong ? ).
Is it possible to provide a dump file? Without one I can only guess what
happens.
In normal conditions if SDL_CreateRenderer fails to create a render
according to your flags it just returns NULL. So I think that you can check
for that and try again with SDL_RENDERER_SOFTWARE.
Maybe some more experienced people can give a better suggestions.

Chees,
Alexandru EneOn Thu, Apr 3, 2014 at 12:20 PM, Mateusz Viste wrote:

Hi all,

I was playing a little bit with the SDL2 library last night, and I hit a
problem that looks like a nasty SDL bug…

I am primarily developing on Linux, and there my code works fine, but then
I tried to port my app to Windows, using a Windows XP system running on a
VirtualBox. The code compiles fine, but whenever it tries to call
SDL_CreateRenderer, the application crashes.

I don’t post my code, because I think it is irrelevant - to be sure, I
also tested with the official code example from there:
https://wiki.libsdl.org/SDL_CreateRenderer

…and it also crashes, at the same moment (calling SDL_CreateRenderer).

This is how I compile the application (I copied the list of parameters
from the sdl-config file shipped with the library):

C:>gcc -O3 -Wall -std=gnu89 test.c -o test.exe -lmingw32 -Dmain=SDL_main
-lSDL2main -lSDL2 -mwindows -Wl,–no-undefined -lm -ldinput8 -ldxguid
-ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32
-lversion -luuid -static-libgcc

The SDL lib I test with is the v2.0.3. I also tested on v2.0.2 - same
result.
The Windows XP virtual machine I am testing this on is a bare, freshly
installed Windows XP service pack 3, without any add-ons.

To avoid crashing, I pass the parameter “SDL_RENDERER_SOFTWARE”. When
using no flags, or the “SDL_RENDERER_ACCELERATED” flag, it crashes.

I presume that the crash is somehow related to the fact that SDL tries to
probe for some acceleration magic, and hangs on it… Now, how should I
proceed to be able to use accelerating on systems that have such
capabilities, and avoid crashing on systems without any powerful GPU (basic
GDI) ?

best regards,
Mateusz


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Only if you activate it in the VM Settings (Display -> Video:
[x] Enable 3D Acceleration) and install the VirtualBox guest additions
in the VM.

So if that is indeed not activated (and/or the guest additions not
installed), there should be no acceleration and SDL should ideally
detect that and fall back to software rendering instead of crashing.
(I can imagine that this case wasn’t tested much, because outside of VMs
you usually always have 3D acceleration)

Cheers,
DanielAm 03.04.2014 11:47, schrieb Alexandru Ene:

Hello,

I would assume that VirtualBox is the problem here ( it might say it has
acceleration, but when SDL is trying to use it something goes wrong ? ).

Hi,

Might be that Virtualbox is doing something wrong, but nonetheless,
having SDL crashing is no good business :stuck_out_tongue:

I do know about the fact that SDL_CreateRenderer() returns NULL when no
acceleration is possible, unfrotunately the problem is that
SDL_CreateRenderer() doesn’t return anything, since the crash occurs
inside it. :confused:

I prepared a little package that contain the example program allowing to
exhibit the problem:
http://www.viste-family.net/mateusz/temp/test-sdl/test.zip

MateuszOn 04/03/2014 11:47 AM, Alexandru Ene wrote:

Hello,

I would assume that VirtualBox is the problem here ( it might say it has
acceleration, but when SDL is trying to use it something goes wrong ? ).
Is it possible to provide a dump file? Without one I can only guess what
happens.
In normal conditions if SDL_CreateRenderer fails to create a render
according to your flags it just returns NULL. So I think that you can
check for that and try again with SDL_RENDERER_SOFTWARE.
Maybe some more experienced people can give a better suggestions.

Chees,
Alexandru Ene

On Thu, Apr 3, 2014 at 12:20 PM, Mateusz Viste <mateusz at viste-family.net <mailto:mateusz at viste-family.net>> wrote:

Hi all,

I was playing a little bit with the SDL2 library last night, and I
hit a problem that looks like a nasty SDL bug..

I am primarily developing on Linux, and there my code works fine,
but then I tried to port my app to Windows, using a Windows XP
system running on a VirtualBox. The code compiles fine, but whenever
it tries to call SDL_CreateRenderer, the application crashes.

I don't post my code, because I think it is irrelevant - to be sure,
I also tested with the official code example from there:
https://wiki.libsdl.org/SDL___CreateRenderer
<https://wiki.libsdl.org/SDL_CreateRenderer>

...and it also crashes, at the same moment (calling SDL_CreateRenderer).

This is how I compile the application (I copied the list of
parameters from the sdl-config file shipped with the library):

C:\>gcc -O3 -Wall -std=gnu89 test.c -o test.exe -lmingw32
-Dmain=SDL_main -lSDL2main -lSDL2 -mwindows -Wl,--no-undefined -lm
-ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32
-loleaut32 -lshell32 -lversion -luuid -static-libgcc

The SDL lib I test with is the v2.0.3. I also tested on v2.0.2 -
same result.
The Windows XP virtual machine I am testing this on is a bare,
freshly installed Windows XP service pack 3, without any add-ons.

To avoid crashing, I pass the parameter "SDL_RENDERER_SOFTWARE".
When using no flags, or the "SDL_RENDERER_ACCELERATED" flag, it crashes.

I presume that the crash is somehow related to the fact that SDL
tries to probe for some acceleration magic, and hangs on it... Now,
how should I proceed to be able to use accelerating on systems that
have such capabilities, and avoid crashing on systems without any
powerful GPU (basic GDI) ?

best regards,
Mateusz
_________________________________________________
SDL mailing list
SDL at lists.libsdl.org <mailto:SDL at lists.libsdl.org>
http://lists.libsdl.org/__listinfo.cgi/sdl-libsdl.org
<http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org>

SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Only if you activate it in the VM Settings (Display -> Video:
[x] Enable 3D Acceleration) and install the VirtualBox guest additions
in the VM.

Yes, you are right - I checked the checkbox about 3D acceleration, and
now the crash is gone.
I was on this track before, but I checked only “2D” acceleration… I
wasn’t expecting SDL to use any kind of “3D” stuff.

So if that is indeed not activated (and/or the guest additions not
installed), there should be no acceleration and SDL should ideally
detect that and fall back to software rendering instead of crashing.

That would be ideal, exactly. Unfortunately the reality is a bit
different - SDL shamelessly crash :slight_smile:

Thanks for the “3D checkbox” hint!

cheers,
MateuszOn 04/03/2014 04:14 PM, Daniel Gibson wrote:

SDL2 typically chooses the Direct3D renderer as the “best choice”, depending on the flags ofc.
VirtualBox probably provides drivers that crash on some Direct3D call when 3D acceleration is not enabled, rather than returning an error code.
If you’re developing on a Linux+X11 system, I definitely think Wine will be a better choice for testing Windows builds (there is a mingw cross-compiler available for Linux, probably in your distro’s package manager even).------------------------
Nate Fries