ioan-chera / eureka-editor

Eureka is a cross-platform map editor for the DOOM engine games.
http://eureka-editor.sourceforge.net/
67 stars 11 forks source link

Consistent segmentation faults when splitting linedef in half on new project #152

Closed boomlinde closed 1 year ago

boomlinde commented 1 year ago

Steps to reproduce

  1. Build from source (commit 21ace56882d457f34911342c45c2fba5c2734862, cc is GCC 12.2.0)
  2. Run and create a new project. I select doom2/vanilla/Doom Format, add no resource wads and call it "test.wad"
  3. Switch to Linedefs mode with l
  4. Select the top line of the default room
  5. Press k to split the linedef

At this point, I get the segfault. If I open a map from doom2.wad and split linedefs in map01, the same problem does not occur.

Analysis

I rebuilt with debug symbols (cmake . -DCMAKE_BUILD_TYPE=debug && make) and could reproduce it then, as well. This is the output from GDB:

Thread 1 "eureka" received signal SIGSEGV, Segmentation fault.
LinedefModule::splitLinedefAtVertex (this=0x5555557b96e8 <gInstance+520>, op=..., ld=1, new_v=4)
    at /home/boomlinde/src/eureka-editor/src/e_linedef.cc:930
930             *L2 = *L;

L is null, which I presume causes the segfault :

L = std::unique_ptr<LineDef> = {get() = 0x0}

Please let me know if you need any further info!

ioan-chera commented 1 year ago

Looks like the classic array realloc problem. Sad thing is that with raw pointers this wasn't a problem! I need to fix it so it doesn't happen again...

ioan-chera commented 1 year ago

Fixed the problem.