JACoders/OpenJK

Segfault on q_math.c:252: irand

Ghostbird opened this issue · 3 comments

Operating system and version:

Debian 11
Just cloned and built default branch.

Is this for single player or multiplayer?

Single player, but I haven't tried multiplayer, so I can't say it does not happen in multiplayer.

Description of the bug (and if possible, steps to reproduce the bug):

Play the game, randomly (literally) it crashes. From the message it seems related to a random number being generated outside the valid range.

openjk/shared/qcommon/q_math.c:252: irand: Assertion `(max - min) < QRAND_MAX' failed.

----- CL_Shutdown -----
Closing SDL audio device...
SDL audio device shut down.
-----------------------
Segmentation fault

What did you expect to happen instead?

No crash

To allow myself to keep playing, I quickly replaced the assertion with a truncation:

if((max - min) >= QRAND_MAX)
{
  max = min + QRAND_MAX;
}

However, I assume that's not the correct solution.

Note: The game is more stable now, but still segfaults occasionally at:

openjk/shared/qcommon/q_math.c:681: ProjectPointOnPlane: Assertion `Q_fabs(inv_denom) != 0.0f' failed.
----- CL_Shutdown -----
Closing SDL audio device...
SDL audio device shut down.
-----------------------
tty]Segmentation fault

The line is:

assert( Q_fabs(inv_denom) != 0.0f );
Lapeth commented

Got this as well, but specific to some areas in the mission to Coruscant and the second Vjun map. It's intermittent, so reloading a lot and getting lucky can circumvent the problem.

Compile with not debug build and the assert won't happen.

D'oh! That makes sense. I added -DCMAKE_BUILD_TYPE=Release to the cmake line and no more problems occurred.