-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SDL software renderer fails with Floating Point Exception #56
Comments
Interesting. We could sidestep this by hiding |
@bunnylin Thanks for this detailed report and the solution.
@suve It seems to happen on calling Alternatively we could just simply add a Linux compiler hint referencing this issue for everybody to figure out themselves what is the best way to solve this in their projects. Downside: The hint will always be present in Linux then. What do you guys think? |
If there was a way to suppress the hint after the developer has addressed it, that would be perfect, but user-specified hints don't get a handy number that could be masked. The visibility may still be preferable... the hint only appears when the unit is compiled, and during normal development you're unlikely to rebuild every unit after each change. |
The downside is though, if someone compiled the units already (ignoring the hint) and later (days, months) runs into the crash he/she is likely not to remember the hint. Well, alternatively we could use the Another alternative would be to introduce a compiler DEFINE for SDL2-For-Pascal hints to be spawned or suppress it. - I guess this would be too much for just one hint atm., but maybe for the future it may be useful to be introduced if further hints are necessary. |
See: PascalGameDevelopment/SDL2-for-Pascal#56 According to this GitHub Issue, when initializing the software renderer on Linux, SDL2 triggers a crash in Mesa code. This happens because FPC and Delphi enable FPE checking by default. This commit disables those exceptions for the duration of SDL2 video initialization, which should prevent crashes while using the software renderer.
This is mostly for visibility - I'm not sure where this would be best fixed.
It seems any SDL application compiled with Pascal will crash if trying to use software renderer video output, on Linux. To verify, run any SDL application with the environment variable
LIBGL_ALWAYS_SOFTWARE=1
set. The failure happens either immediately onSDL_InitSubSystem(SDL_INIT_VIDEO)
, or when callingSDL_CreateRenderer
. The error that appears can beEInvalidOp: Invalid floating point operation
orEDivByZero: Division by zero
depending on environment.Doing this through GDB, I got this callstack pointing at the LLVMpipe software rasterizer:
So it's a problem in Mesa. This doesn't affect Pascal/SDL programs on Windows since users don't normally run Mesa there. An internet search turned up this bug: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3096
They say the FPE should normally not be enabled in the first place, and the caller should just disable the exception mode. A commenter notes that the affected software was made with Delphi, which suggests to me that Free Pascal and Delphi are both deliberately keeping this FPE enabled (and are unlikely to change that because it would break compatibility).
As a workaround, it's simple to disable the exception by applying a mask, via the Math unit:
The text was updated successfully, but these errors were encountered: