Skip to content
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

Segfault in Single Player #1021

Closed
Fallstar opened this issue Aug 27, 2019 · 17 comments
Closed

Segfault in Single Player #1021

Fallstar opened this issue Aug 27, 2019 · 17 comments

Comments

@Fallstar
Copy link

Fallstar commented Aug 27, 2019

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
Copy link
Member

Any bt on the segfault?

@Fallstar
Copy link
Author

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

@Fallstar
Copy link
Author

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

@Fallstar
Copy link
Author

Ok, got it!
In

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
Copy link
Member

xycaleth commented Aug 28, 2019 via email

@Fallstar
Copy link
Author

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 by G_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
Copy link

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).

vilhelmgray added a commit to vilhelmgray/OpenJK that referenced this issue Nov 14, 2019
The defaultStyle array only has 14 valid entries currently. When the
15th element is accessed, it returns a null-byte (not an empty string).
This commit prevents a segmentation fault by checking whether the
returned pointer from G_SpawnString is NULL before calling strlen.

Fixes: JACoders#1021
@mipek
Copy link

mipek commented Nov 14, 2019

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

@vilhelmgray
Copy link

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
Copy link
Member

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
Copy link

vilhelmgray commented Nov 27, 2019

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
Copy link

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
Copy link

mipek commented Nov 30, 2019

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

@Fallstar
Copy link
Author

Fallstar commented Dec 2, 2019

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

@Fallstar Fallstar closed this as completed Dec 2, 2019
@sodomon2
Copy link

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
Copy link

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

@vilhelmgray
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants