PDA

View Full Version : Debugging an SDL2 application raise floting point error



KidPaddle
06-12-2016, 06:11 AM
Hi,

i have a strange effect debugging a SDL2, Version 2.05, application on Windows (8.1)/Linux (Ubuntu 16) with Delphi (7 and 2009) or Lazarus (1.6).

Calling SDL_Init(SDL_INIT_VIDEO) inside both IDE's raise a floating point exception. Running program from console all works, but running inside IDE it raise the error.

I have searched but found nothing. Has anyone a hint for me?

Greetings
Thomas

SilverWarior
06-12-2016, 07:25 PM
I would guess that this is one of the examples where your debugger catches and reports the Exception that is probably properly handled in the next line or next few lines. I assume this since you only know that exception is being raised during the debugging session.

So I wouldn't worry to much about it unless it causes your application to fail (can't debug further after clicking on continue instead of break). If it does it would be good if you could post us more information as to where and when is such exception raised so someone can check to see if SDL2 code might be bugged.

KidPaddle
07-12-2016, 06:42 AM
Thanks for help.

I#m using SDL 2 Headers from https://github.com/ev1313/Pascal-SDL-2-Headers

Windows 8.1 with Delphi 2009 or Lazarus 1.6:
<pre>
program SDL2Test;

uses SDL2;

begin
if (SDL_Init(
SDL_INIT_VIDEO
or SDL_INIT_AUDIO
or SDL_INIT_TIMER
//or SDL_INIT_JOYSTICK
//or SDL_INIT_HAPTIC
//or SDL_INIT_GAMECONTROLLER
) = 0) then begin
SDL_Quit();
end;

end.
</pre>

Very simple, nothing special, this program stopps after fpe exception is raised inside both ide's. Comment "or SDL_INIT_TIMER" out, i can debug the program. Using any option of SDL_INIT_TIMER / SDL_INIT_JOYSTICK / SDL_INIT_HAPTIC / SDL_INIT_GAMECONTROLLER raise the exception. This is on Windows 8.1.

Same program on Ubuntu 16.04 raise fpe exception if SDL_INIT_VIDEO used, any other option can be used with out problems.

Very strange.

Thomas

imcold
22-06-2017, 07:57 PM
SDL2 2.0.5 raises a debugger exception to name threads at start, this seems to conflict with debugging through gdb. Add a call to SDL_SetHint(SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING , '1'); to prevent SDL from doing this.

imcold
02-10-2017, 02:43 PM
Fyi - this is no longer needed since 2.0.6: it sets the SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING hint by default.