JACoders / OpenJK

Community effort to maintain and improve Jedi Academy (SP & MP) + Jedi Outcast (SP only) released by Raven Software
GNU General Public License v2.0
2.03k stars 614 forks source link

Segfault in Single Player #1021

Closed Fallstar closed 4 years ago

Fallstar commented 5 years ago

Reporting a bug? Please make sure you've given the following information - thanks!

Operating system and version: Arch Linux, using Wayland

Is this for single player or multiplayer? Single Player

Description of the bug (and if possible, steps to reproduce the bug): Segfault when starting a new game, after character creation. Multiplayer works fine though, so I doubt it's related to my graphical environment configuration. I built it today using the AUR pkgbuild. It happens when using both x11 or Wayland driver for SDL.

What did you expect to happen instead? Start playing.

PS: I don't know if it's relevant, but I get this exact same behavior with Jedi Outcast.

ensiform commented 5 years ago

Any bt on the segfault?

Fallstar commented 5 years ago

Nothing explicit, it happens during Game Initialization. Here's the full output: https://hastebin.com/gadiyimuye

Fallstar commented 5 years ago

If you don't know what could cause this, I'll build it again with the debug flag to try and find out.

Fallstar commented 5 years ago

Ok, got it! In https://github.com/JACoders/OpenJK/blob/e8b5c135eccb05ddae67e00ff944001f373fddd4/code/game/g_spawn.cpp#L1341 defaultStyles contains 14 correct entries, then only empty strings. Segfault occurs at line 1512 when it tries to get the length of an empty string.

I fixed it by setting all empty strings to z, like the normal style. The game now seems to work fine. Can you think of a better way to fix it?

xycaleth commented 5 years ago

That’s really weird! The length of an empty string is always (or should always be) 0. What map are you loading and do you have any mods?

On 28 Aug 2019, at 17:18, Fallstar notifications@github.com wrote:

Ok, got it! In https://github.com/JACoders/OpenJK/blob/e8b5c135eccb05ddae67e00ff944001f373fddd4/code/game/g_spawn.cpp#L1341 defaultStyles contains 14 correct entries, then only empty strings. Segfault occurs at line 1512 when it tries to get the length of an empty string.

I fixed it by setting all empty strings to z, like the normal style. The game now seems to work fine. Can you think of a better way to fix it?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

Fallstar commented 5 years ago

Yeah, my C++ is rusty so I don't really understand everything, it's not the value from the table that's directly used. It's set byG_SpawnString which uses pointer things I'm not used to.

I'm trying to load yavin1 with no mods. Just trying to play the vanilla solo game. :)

vilhelmgray commented 5 years ago

That’s really weird! The length of an empty string is always (or should always be) 0.

Those aren't empty strings: {""} is evaluating as {0x0}. The segmentation fault occurs since the call becomes strlen(0x0).

mipek commented 4 years ago

Thank you! I had the same issue and confirm that fixes it

vilhelmgray commented 4 years ago

By the way, it looks like the original code works when compiled as C but not as C++ so this is might be one of those small but significant differences between the two languages.

xycaleth commented 4 years ago

This problem seems specific to Linux - I tried to reproduce on macOS but I didn't encounter a crash when starting a new game. I don't have a Linux system available right now to debug this - can we confirm that G_SpawnString is returning the default value passed in (the value from defaultStyles) and that the default value is null?

@vilhelmgray what OS are you running to reproduce the problem?

vilhelmgray commented 4 years ago

I wasn't quite sure why this was occuring, so I opened a StackOverflow question to figure it out. Turns out it might be a regression in the latest version of g++, so I'll open up a bug notice to the developers and report back here what they say.

vilhelmgray commented 4 years ago

This issue is likely the result of a regression in GCC that has fortunately been fixed for GCC version 9.3: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90947

@mipek @Fallstar Which compiler and version are you using.

mipek commented 4 years ago

@vilhelmgray Thanks for the heads up! I was using GCC version 9.1

Fallstar commented 4 years ago

I was using 9.2, so it makes sense, thanks!

sodomon2 commented 4 years ago

I have a mistake similar to this but what is a bug with opengl well the game crashes when you start the mission #1 and makes the game close here the bug

PIXELFORMAT: color(24-bits) Z(24-bit) stencil(8-bits) MODE: -2, 1024 x 600 fullscreen hz:N/A GAMMA: hardware w/ 0 overbright bits rendering primitives: single glDrawElements texturemode: GL_LINEAR_MIPMAP_LINEAR picmip: 0 texture bits: 0 multitexture: enabled compiled vertex arrays: enabled texenv add: enabled compressed textures: enabled compressed lightmaps: disabled texture compression method: GL_EXT_texture_compression_s3tc anisotropic filtering: enabled (16 of 16) Dynamic Glow: disabled Extended sound quality field to contain very high option. Disabling eax field because current platform does not support EAX. Hiding eax_icon object because current platform does not support EAX. Extended subtitles field to contain all voiceovers option. UI menu load time = 66 milli seconds ^3Saltando secuencia de v�deo... ...loaded 818 faces, 26 meshes, 150 trisurfs, 0 flares ^3WARNING: RE_RegisterSkin( 'models/players/player/model_default.skin' ) failed to load! ^3Saltando secuencia de v�deo... tty]Illegal instruction

sodomon2 commented 4 years ago

My mistake seems to be because of the dates since I tried to compile another engine and it gives me the same error

vilhelmgray commented 4 years ago

@sodomon2 I think your error is different than the original segfault error for this issue page. Open a new Github issue for your error and we can troubleshoot it there.