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

invalid index used in array script #713

Closed
GitInMotion opened this issue May 4, 2023 · 7 comments
Closed

invalid index used in array script #713

GitInMotion opened this issue May 4, 2023 · 7 comments

Comments

@GitInMotion
Copy link

Was playing D2 vertigo level 8 with the guide bot by the red door. Error happened a few times:

https://imgur.com/a/YYeEoC3
image

@vLKp
Copy link
Contributor

vLKp commented May 4, 2023

When filing a report like this, please follow the steps in ISSUE_TEMPLATE/02-runtime-crash.md, which in particular prompt you for the build that you are playing and steps to reproduce. The cited line is impossible for the current code, because that line is blank.

If you tell what build you used, I can map the cited line to the corresponding code. A dump file would also be quite helpful for reporting the state of the game at the time of the crash.

@GitInMotion
Copy link
Author

I was running build dxx-rebirth_20220929-win
I'm not sure what you're referring to with ISSUE_TEMPLATE/02-runtime-crash.md :-/

Here is the savegame right before it crashes: https://www.dropbox.com/s/kjlhrls978zqyse/livenuke.sg0?dl=0

@vLKp
Copy link
Contributor

vLKp commented May 9, 2023

When you try to file an issue, Github presents you with:

https://github.com/dxx-rebirth/dxx-rebirth/issues/new/choose

On that page, it offers you:

  • Failure to build
  • Runtime crash
  • Runtime bug

and a link at the bottom for using none of those templates. You appear to have used none of them, so you skipped over the instructions in Runtime crash. In particular, you skipped over:

If the issue occurs at some particular place in the level, give a description how to reach that point from the beginning of the level.  Assume that the maintainer can use cheats to acquire keys, skip difficult fights, etc., but that the maintainer is not familiar with the optimal route to get from the start point to the affected location.
- Steps, starting from the main menu, to reach the problem state.  Assume the maintainer can cheat to any level and knows Descent input controls, but is unfamiliar with the particular level.
- If possible, describe the frequency of the problem.  Does it happen every time the steps to reproduce are followed?  If it is intermittent, are there any events correlated with the error?
- If the game produced any error messages, include their text verbatim.  If you paraphrase the message, you will likely be asked to reproduce the error and collect a verbatim copy of the text.

The error message as text would be nice to record, so that it can be quoted and searched. Your screenshot of the error message is not searchable. The instructions in your screenshot also state to "provide steps to reproduce, starting from the game main menu."

For my future use, the error message in your screenshot reads:


Rebirth encountered a fatal error.  Please report this to the developers.

Include in your report:
* The exception message text:
  "d2x-rebirth/main/escort.cpp:718: invalid index used in array subscript: base=00007ff75fca0e68 size=350 index=65535"
* The level(s) played this session, including download URLs for any add-on missions

Dump file generation is not enabled in this build.

To the extent possible, provide steps to reproduce, starting from the game main menu.

Please prefer attaching critical files to the ticket, rather than hosting them on external services that may delete them unexpectedly.

Using that savegame, I see a different, but bad behavior. After loading, the Guidebot seems stuck on the red door for several seconds, then I get these messages on the terminal:

d2x-rebirth/main/escort.cpp:716: BUG: object 0x555555f80bf0 has type 255, expected 2
/usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/array:208: constexpr std::array<_Tp, _Nm>::value_type& std::array<_Tp, _Nm>::operator[](size_type) [with _Tp = d2x::robot_info; long unsigned int _Nm = 85; reference = d2x::robot_info&; size_type = long unsigned int]: Assertion '__n < this->size()' failed.

Then the program aborts due to the failed assertion. This differs from your report, where the crash is an invalid Buddy_objnum. I see a valid Buddy_objnum that points to an invalid d2x::object. This is strange, since Buddy_objnum should either be object_none if there is no Guidebot, or should refer to the d2x::object representing the Guidebot. I can see the Guidebot in front of me at the red door, so there is a Guidebot on the level. Therefore, Buddy_objnum ought to refer to it, but instead refers to an invalid or destroyed object. How did you get the game into this state? Was the Guidebot killed and recreated? Have you used any cheats on this level?

@vLKp
Copy link
Contributor

vLKp commented May 16, 2023

After bypassing the crash, this save looks strange. I found a marker for the guidebot death site, even though there is a live guidebot in play. This should not happen in normal play. Additionally, the player has ~90 seconds left on invulnerability at load time, which is not possible normally.

@GitInMotion
Copy link
Author

GitInMotion commented May 17, 2023 via email

@vLKp
Copy link
Contributor

vLKp commented May 17, 2023

The invulnerability was a tell that you were using cheats, but did not cause the problem. The resurrected guidebot, with a different internal index than the original, is the problem. After the game loads, the index of the original (now dead) guidebot is used for some operations, and the object at that index now is not a guidebot, so those operations crash.

You might be able to avoid the crash by telling the guidebot to go away. I have a patch that fixes this, which I hope to push soon.

vLKp added a commit that referenced this issue May 21, 2023
The index of the guidebot is set by loading the level data, and this is
usually sufficient.  However, if the user kills the guidebot, then uses
cheats to create a new one, the new guidebot will often have a different
index than the original guidebot.  If such a game is saved and then
reloaded, then after the reload, the computed guidebot index will be
reverted to the index of the original dead guidebot.  This causes
various problems, including potentially a crash.  Recompute the guidebot
index after loading the objects from the save file, so that it matches
the live guidebot.

Reported-by: GitInMotion <#713>
@vLKp
Copy link
Contributor

vLKp commented May 21, 2023

I believe the above commit will allow your game to load and not crash when the guidebot performs its next update. Please sync to master and retry. If you still see problems, please reopen.

@vLKp vLKp closed this as completed May 21, 2023
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

No branches or pull requests

2 participants