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

Save/Load corruption bug for native Linux #7

Closed
bryanperris opened this issue Apr 16, 2024 · 15 comments · Fixed by #140
Closed

Save/Load corruption bug for native Linux #7

bryanperris opened this issue Apr 16, 2024 · 15 comments · Fixed by #140
Labels
64bit Issue or pull relates to 64bit bug Something isn't working

Comments

@bryanperris
Copy link
Contributor

How to reproduce:

  1. Install the game from Steam on a Linux based system (Steam Deck for me)
  2. Start a new game and make a save
  3. Attempt to load the save, sometimes it will be fine.
  4. If the game saves a bad save file, it crashes the game upon load.
@kevinbentley
Copy link
Member

Can you verify that this bug still exists once the source has been compiled? We fixed a bunch of bugs that never made it into release. I'll try to find the list we had.

@bryanperris
Copy link
Contributor Author

Do you have the official build instructions I should follow for Linux? Once its built, I can make a duplicate of the D3 Steam directory, and replace the binary executable with the GitHub version to test on the Steam Deck.

@JeodC JeodC added the bug Something isn't working label Apr 17, 2024
@bryanperris
Copy link
Contributor Author

I think for my reported tickets, there should be a Steam label just to track, I found this issue from Steam version and not from this repo.

@JeodC
Copy link
Collaborator

JeodC commented Apr 18, 2024

I think for my reported tickets, there should be a Steam label just to track, I found this issue from Steam version and not from this repo.

If you can test and verify the bug exists in source, then leave it be. If it's not reproducible, close it. We should not be tracking steam version bugs.

@bryanperris
Copy link
Contributor Author

Agreed, I meant more that the label to mark 'bug' issues not being related to this repo, I have no doubt others will also post here bugs they found on Steam D3 version.

@JeodC JeodC added icculus Something in the 2020 port by Ryan Gordon that may or may not be applicable here and removed bug Something isn't working labels Apr 18, 2024
@JeodC
Copy link
Collaborator

JeodC commented Apr 18, 2024

Author

I can see how that could cause confusion. Label created and applied.

@bryanperris
Copy link
Contributor Author

bryanperris commented Apr 19, 2024

This issue does exist.

I am playing level 1, saved a few times, used some cheats, save again.
Then I quit the game back to the main menu, then load my file.

So in the terminal a lot of these messages
RECOMPILE YOUR SCRIPTS!!!
Game-Checksum FAIL!!! (2273889867l!=2273873307l)
RECOMPILE YOUR SCRIPTS!!!
Game-Checksum FAIL!!! (2273889867l!=2273873307l)
RECOMPILE YOUR SCRIPTS!!!
Game-Checksum FAIL!!! (2273889867l!=2273873307l)
RECOMPILE YOUR SCRIPTS!!!
Game-Checksum FAIL!!! (2273889867l!=2273873307l)
RECOMPILE YOUR SCRIPTS!!!

Then what I caught in GDB:
Thread 1 "Descent3" received signal SIGSEGV, Segmentation fault. 0x000000000053ae1a in ObjUnlink (objnum=236) at /home/bperris/base/dev/Descent3/Descent3/object.cpp:1478 1478 seg->objects = obj->next;

Stacktrace
#2 0x000000000053ae1a in ObjUnlink (objnum=236) at /home/bperris/base/dev/Descent3/Descent3/object.cpp:1478 #3 0x000000000053c356 in ObjDelete (objnum=236) at /home/bperris/base/dev/Descent3/Descent3/object.cpp:1899 #4 0x00000000004cde11 in LGSObjects (fp=0x169a8f0, version=2) at /home/bperris/base/dev/Descent3/Descent3/loadstate.cpp:964 #5 0x00000000004cc06f in LoadGameState (pathname=0x7dabc0 <LGS_Path> "/home/bperris/Descent3/savegame/saveg000") at /home/bperris/base/dev/Descent3/Descent3/loadstate.cpp:343 #6 0x000000000048e73e in LoadCurrentSaveGame () at /home/bperris/base/dev/Descent3/Descent3/gamesave.cpp:700 #7 0x0000000000490f65 in GameSequencer () at /home/bperris/base/dev/Descent3/Descent3/gamesequence.cpp:1222 #8 0x0000000000471f3d in PlayGame () at /home/bperris/base/dev/Descent3/Descent3/game.cpp:814 #9 0x00000000004647be in MainLoop () at /home/bperris/base/dev/Descent3/Descent3/descent.cpp:598 #10 0x000000000046466e in Descent3 () at /home/bperris/base/dev/Descent3/Descent3/descent.cpp:553 #11 0x00000000005e6b37 in oeD3LnxApp::run (this=0x7fffffffd470) at /home/bperris/base/dev/Descent3/Descent3/lnxmain.cpp:237 #12 0x00000000005e6a6b in main (argc=1, argv=0x7fffffffd678) at /home/bperris/base/dev/Descent3/Descent3/lnxmain.cpp:737

@JeodC JeodC added bug Something isn't working and removed icculus Something in the 2020 port by Ryan Gordon that may or may not be applicable here labels Apr 19, 2024
@bryanperris
Copy link
Contributor Author

bryanperris commented Apr 19, 2024

@kevinbentley
I have applied this change to object.cpp line 1475:
terrain_segment *seg = &Terrain_seg[cellnum & 0xFFFF];

No more crash, my save file loads, ship restores to the right place, gameplay seems normal, I am not sure how to verify all the information without some kind of compare log between memory states. Poking you, if it make sense that cellnum should be wrapping around on the terrain table.

Edit: so I noticed the terrain segment isn't null, but has some non-zero memory address, then printed the cellnum value, and noticed it way beyond the table's memory range, so no longer it was crashing. I would like to investigate more on why the cellnum went beyond the range anyways.

I found the cellnum mask: #define ROOMNUM_CELLNUM_MASK 0x7fffffff
This signed 32-bit mask is way larger than 16 bits.

@JeodC
Copy link
Collaborator

JeodC commented Apr 20, 2024

@kevinbentley I have applied this change to object.cpp line 1475: terrain_segment *seg = &Terrain_seg[cellnum & 0xFFFF];

No more crash, my save file loads, ship restores to the right place, gameplay seems normal, I am not sure how to verify all the information without some kind of compare log between memory states. Poking you, if it make sense that cellnum should be wrapping around on the terrain table.

Edit: so I noticed the terrain segment isn't null, but has some non-zero memory address, then printed the cellnum value, and noticed it way beyond the table's memory range, so no longer it was crashing. I would like to investigate more on why the cellnum went beyond the range anyways.

I found the cellnum mask: #define ROOMNUM_CELLNUM_MASK 0x7fffffff This signed 32-bit mask is way larger than 16 bits.

Is this resolved or just partially resolved?

@bryanperris
Copy link
Contributor Author

I don't feel it is resolved, only found a simple way to avoid the crash. It is going to take time to figure out a better solution since it doesn't affect Windows builds.

@bryanperris
Copy link
Contributor Author

closer to the issue here:
when load routines reads in the objects, it is reading in a negative value

Read roomnum: -2147447883
Read roomnum: -2147447883

@winterheart winterheart added the 64bit Issue or pull relates to 64bit label Apr 20, 2024
@bryanperris
Copy link
Contributor Author

here is a dump of read room numbers from the object file
https://pastebin.com/p8qVPSJ9

@bryanperris
Copy link
Contributor Author

I applied the 16-bit mask to all of the terrain cell calls, but I cannot open the first door in level 2 after loading my problematic save file.

@viggen66
Copy link

Can you share your compiled Descent3 binary with saved game fixed?

@bryanperris
Copy link
Contributor Author

I have not fixed the issue but only prevent crashing with a hack, still investigating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
64bit Issue or pull relates to 64bit bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants