TTimo / GtkRadiant

The open source, cross platform level editor for idtech games
http://icculus.org/gtkradiant/
Other
581 stars 152 forks source link

segfault on release build since XDG_STATE_HOME change #689

Closed Kevin-Delnoije closed 1 year ago

Kevin-Delnoije commented 1 year ago

When compiling on a ubuntu 22.04 lts system with gcc 11.3.0 gtkradiant compiles succesfully, but when launching the binary a segfault occurs. This only only happens in release mode.

I added a releasewithdebug config in config.py

     elif ( config == "debugwithrel"):
          env.Append( CFLAGS = [ '-g','-O2'] )
          env.Append( CXXFLAGS = [ '-g', '-O2'] )

          # this lets us catch libjpg and libpng libraries that we put in the same directory as radiant.bin
          env.Append( LINKFLAGS = ['-Wl,-rpath,.'] )

in gdb when launching the the executable build in release with debug info you can see that the argv variable is optimized out.

Thread 1 "radiant.bin" hit Breakpoint 1, mainRadiant (argc=<optimized out>, argv=<optimized out>) at radiant/main.cpp:507
507     g_strTempPath += "/.radiant/";
(gdb) display argv
1: argv = <optimized out>
(gdb) display argv[0]
2: argv[0] = <error: value has been optimized out>
(gdb) n
146     return m_pStr;
1: argv = <optimized out>
2: argv[0] = <error: value has been optimized out>

...

513     loki_init_datapath( argv[0] );
1: argv = <optimized out>
2: argv[0] = <error: value has been optimized out>
(gdb) 

Thread 1 "radiant.bin" received signal SIGSEGV, Segmentation fault.
0x00005555555a570b in loki_get_datapath () at radiant/main.cpp:209
209 }
(gdb) 

The commit before works fine so probably some aggresive optimizations happen when the compiler detects that the environment variable is always empty?

const char *xdg_state_home = getenv( "XDG_STATE_HOME" );

this line is also optimized out

TTimo commented 1 year ago

Right, I made some changes around there for the flatpak support, and we're now seeing a crash in release config. See https://github.com/TTimo/GtkRadiant/issues/574#issuecomment-1466235446 - I haven't spent time trying to track it down yet. Patches welcome..

TTimo commented 1 year ago

Could be fixed by https://github.com/TTimo/GtkRadiant/pull/686/commits/8d3a9735370581a1e1c9243265386eccffac3050 if you're able to check.

Kevin-Delnoije commented 1 year ago

could not test the exact commit because of this message on github . "This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository."

it seems to work when i apply the changes manually because i do not get segmentation fault anymore. release and debug behave the same now :)

on startup i encounter this message on both release and debug "No games setup, aborting errno: No such file or directory An unrecoverable error has occured."

btw to compile the project i need to comment out the following line in bytebool.h

typedef qboolean bool;
TTimo commented 1 year ago

thanks, fix is in