bvschaik / julius

An open source re-implementation of Caesar III
GNU Affero General Public License v3.0
2.85k stars 317 forks source link

Game crashes on Save attempt #676

Closed ChrKn closed 1 year ago

ChrKn commented 1 year ago

Julius 1.7.0 on Windows 10 using the GOG version of C3.

Okay, this is a weird one. It only happens, when there are exactly 100 saves and the name for the save file would be the last in the list, e.g.

a.sav b.sav ... z.sav zzz.sav « new file

I have attached three sets of save files to potentially reproduce the problem. Should in theory work whenever there are 100 saves. The files I have renamed are Trading Trouble 01 to 15, because those were the ones I first encountered the bug with and used to try to narrow it down with.

  1. Save-Files Default Names.zip
  2. Save-Files renamed to A.zip
  3. Save-Files renamed to z.zip

Tests I have done:

  1. Load any save or start a new game and try to save it as Trading Trouble 16.sav or z.sav >> game crashes. Save as anything that is not the last save in the list and Trading Trouble 16 afterwards >> everything is fine.
  2. Try to save as A 16.sav >> Game does not crash. Afterwards I can save as z.sav or whatever no problem. If I try to save as z.sav right away it crashes again.
  3. Try so save as z 16.sav or zz.sav and the game crashes. Save as anything that is not the last save in the list and z 16.sav afterwards >> everything is fine.
crudelios commented 1 year ago

Ah, what a specific crash.

I think I know the overall cause of the crash, but I'll need to debug the code to fix it.

bvschaik commented 1 year ago

Thanks for the report and thorough investigation! I managed to reproduce it on Mac as well, it crashes with the following stacktrace:

ERROR: Oops, crashed with signal 11 :(
INFO:   0   julius                   0x0000000102be7a1a backtrace_print + 42
INFO:   1   julius                   0x0000000102be38a5 handler + 37
INFO:   2   libsystem_platform.dylib 0x00007fff77fb4b5d _sigtramp + 29
INFO:   3   AppKit                   0x00007fff49e52f96 GCC_except_table7 + 2250
INFO:   4   julius                   0x0000000102be2cf4 platform_file_manager_compare_filename_prefix + 36
INFO:   5   julius                   0x0000000102cb3b31 find_first_file_with_prefix + 193
INFO:   6   julius                   0x0000000102cb38ef scroll_to_typed_text + 111
INFO:   7   julius                   0x0000000102cb32b6 handle_input + 294
INFO:   8   julius                   0x0000000102c7e7bd window_draw + 125
INFO:   9   julius                   0x0000000102c4c76b game_draw + 11
INFO:   10  julius                   0x0000000102be37ca run_and_draw + 26
INFO:   11  julius                   0x0000000102be383f main_loop + 95
INFO:   12  julius                   0x0000000102be358f main + 95
INFO:   13  libdyld.dylib            0x00007fff77dc93d5 start + 1
ChrKn commented 1 year ago

That was quick. I was unsure if such a weird and specific crash would even warrant a fix attempt.