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

AI/server crash -possible bad ship design? #3617

Closed
indywatch opened this issue Dec 18, 2021 · 2 comments
Closed

AI/server crash -possible bad ship design? #3617

indywatch opened this issue Dec 18, 2021 · 2 comments
Labels
category:bug The Issue/PR describes or solves a perceived malfunction within the game. component:internal The Issue/PR deals with any project component that has no explicit `component` label. status:resolved The Issue was resolved, either by answering properly or fixing the underlying bug.
Milestone

Comments

@indywatch
Copy link

Bug Report

Environment

  • FreeOrion Version: v0.4.10+ [build 2021-12-13.d81306e] CMake (snap)
  • Operating System: Debian 4.19.5-2~mx17+1 (2018-12-12) x86_64 GNU/Linux
  • Graphic card used: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09)
  • Fetched as
    • Weekly development build

Description

Server exits during AI turn, client disconnects from server. Game crashes. Locally reproducible each time I load my save file.

Expected Result

None of that.

Steps to reproduce

  • Load Save file
  • Wait
  • Crash!

freeorion.log
freeoriond.log
AI_4.log
FreeOrion_Coordinator_Helpers_0512_20211218_210534.sav.log

@indywatch indywatch added the category:bug The Issue/PR describes or solves a perceived malfunction within the game. label Dec 18, 2021
@geoffthemedio
Copy link
Member

I'm not sure why or where exactly it happens, but at some stage in determining the targets for an effect, it was making a duplicate of a ship (id: 6830) that seems to have a valid design when viewed in the ObjectsList in the client, but which didn't have a valid ID at that point in the code. This lead to an attempt to create a temporary ship for calculating ship damage to fail, which lead to a crash. I've added some safety checks and reworked some things to avoid doing the temporary ship creation at all when not really needed, which seems to stop the crash. There might be some additional minor issues related to this, but it's harder to completely figure out what's going on than just fix the symptoms for now...

@geoffthemedio geoffthemedio added component:internal The Issue/PR deals with any project component that has no explicit `component` label. priority:high The Issue/PR is very urgent or important and should be addressed/finished as soon as possible. status:resolved The Issue was resolved, either by answering properly or fixing the underlying bug. labels Dec 19, 2021
@geoffthemedio geoffthemedio added this to the v0.5 milestone Dec 19, 2021
@Vezzra Vezzra removed the priority:high The Issue/PR is very urgent or important and should be addressed/finished as soon as possible. label Dec 19, 2021
@geoffthemedio
Copy link
Member

After investigating more, I think the sequence of events was:
-An empire detects another empire's ship at basic visibility, which sets the ship's design to -1, indicating unknown design
-Some time later, the empire attempts to calculate how many armed ships are in a fleet or system as part of the Flanking policy calculations
-As part of that calculation, it calculates the weapon damage for each ship, in order to check if it is > 0 and thus the ship qualifies as armed
-To do that, it creates a temporary copy of the ship that can be used as a mutable target object in the context of a ValueRef evaluation
-Creating the copy involves constructing a new ship object by passing the design ID, here -1
-The Ship class constructor throws an exception if passed a ship design ID that isn't the ID of a ship design, which -1 is not.

Should be fixed now, in that it won't crash. A ship with no valid design ID will be considered as not armed for client-side estimtaions of how many armed ships are present somewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:bug The Issue/PR describes or solves a perceived malfunction within the game. component:internal The Issue/PR deals with any project component that has no explicit `component` label. status:resolved The Issue was resolved, either by answering properly or fixing the underlying bug.
Projects
None yet
Development

No branches or pull requests

3 participants