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

Crash Trader.lua #5653

Closed
TheFelin opened this issue Oct 29, 2023 · 6 comments · Fixed by #5657
Closed

Crash Trader.lua #5653

TheFelin opened this issue Oct 29, 2023 · 6 comments · Fixed by #5657

Comments

@TheFelin
Copy link

TheFelin commented Oct 29, 2023

Observed behaviour

sometimes on mission

Expected behaviour

Steps to reproduce

My pioneer version (and OS):
Linux Kubuntu last Kernel
and last Git Pioneer
pioneerbug1
pioneerbug2

My output.txt (required) and game save (optional, but recommended)
I can't find output.txt but I have a backup just before the bug

@Web-eWorks
Copy link
Member

@Max5377 I believe you have or are addressing this issue as part of your bugfix PRs?

@Max5377
Copy link
Contributor

Max5377 commented Oct 29, 2023

@Web-eWorks Yes, but I haven't done PR to fix this yet. I mentioned this issue first here and the cause and possible solution for this here.
Update: This issue was discovered by this PR which fixes saving of usedCargo property which is used in the Trader.addEquip:
assert(ship.usedCargo == 0, "equipment is only installed on an empty ship")

@cwyss
Copy link
Contributor

cwyss commented Nov 11, 2023

I also experienced the issue, did some testing, and came up with a route through Barnard's system that will consistently reproduce the issue -- see below for details and game saves.

I then tried the same test route with the suggested PR #5657. Unfortunately, this PR does not seem to fix the problem: the crash still happens, although it takes a little longer to appear.

The test route

I used the following tour through Barnard's star system. Important (probably, as this is supposed to be connected to saving): After completing each stage,

  • save game,
  • end game, then
  • load the saved game again.

The stages were

  1. start new game at Barnard's star; sell radar and atm. shielding
  2. autopilot fly&dock OPLI Contemplation
  3. autopilot fly&dock High Sec. Prison Tranquility; sell cargo H2, refuel full
  4. autopilot fly&dock OPLI Pax, refuel
  5. autopilot fly&dock System Administration Resting, refuel
  6. autopilot fly&dock High Sec. Prison Serenity

Results

I also checked that this is reproducible, by rerunning the whole test route from stage 1. Interestingly, one such rerun for PR #5657 yielded the crash already at stage 4, just as in master. Another rerun then made it again into stage 6.

@Max5377
Copy link
Contributor

Max5377 commented Nov 12, 2023

@cwyss If you loaded old save with (#5657) then it will not work, because this uses different array to get objects when saving and loading the game.
And to get this crash you don't even have to do this steps. Just load any save, save the game, load, set max speed and wait for some time.
Adding: there should be at least one hyperspace ship and one station in the system when saving the game.

@cwyss
Copy link
Contributor

cwyss commented Nov 13, 2023

@cwyss If you loaded old save with (#5657) then it will not work, because this uses different array to get objects when saving and loading the game.

When doing the test with #5657, I did not use an old save, but started again from scratch with "New Game" from the main menu. That is, I did the whole test route in #5657, as described.

And to get this crash you don't even have to do this steps. Just load any save, save the game, load, set max speed and wait for some time.

That's of course much easier :-)

@Max5377
Copy link
Contributor

Max5377 commented Nov 13, 2023

@cwyss Yeah, looks like something happens when the game gets saved second time and more in the same system. Sometimes save gets corrupted so bad that it can't even find json key when loading it for objects (for now, it's mainly Sfx and pos key, can occur even without PR).
Thanks, for spotting this.
Update: for #5657, not all objects was saving, because if LuaObjectBase::SerializeComponents returns false in LuaSerializer::SaveComponents, for loop would stop execution. Changed break to continue, saved the game multiple times and haven't seen this error. I'll update more if I see new errors by this change.

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.

4 participants