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

Handle nullptr in spawn-monsters-submap #70880

Merged

Conversation

physics-enthusiast
Copy link
Contributor

@physics-enthusiast physics-enthusiast commented Jan 13, 2024

Summary

Bugfixes "Handle nullptr in spawn-monsters-submap"

Purpose of change

Fix #70650.
When checking for missions attached to spawning monsters, the case where mission::find fails and returns a nullptr is not handled, presumably leading to a segmentation fault somewhere down the line.

Describe the solution

Add a check for null pointers before proceeding to operate on the returned mission. The debug message for failing to find the mission with the appropriate mission id has been intentionally left in since whatever is causing the failure would still be considered a (separate) bug, it just shouldn't cause a SIGSEGV now.

Describe alternatives you've considered

Testing

Game compiles, no longer segfaults.

Additional context

@github-actions github-actions bot added [C++] Changes (can be) made in C++. Previously named `Code` <Bugfix> This is a fix for a bug (or closes open issue) json-styled JSON lint passed, label assigned by github actions labels Jan 13, 2024
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Jan 13, 2024
@github-actions github-actions bot added the astyled astyled PR, label is assigned by github actions label Jan 13, 2024
@physics-enthusiast
Copy link
Contributor Author

Still preliminary hypothesis, but seems the root cause of #70650's particular missing mission is that if a mission is supposed to spawn monsters but fails before they have spawned (in this case because the mission location never enters the reality bubble before it is declared a failure by an EOC), the submap spawns list (which contains a reference to the mission id) is never updated by set_finish_mission or remove_active_mission and still attempts to spawn monsters by attempting to access the details of a now nonexistent mission.
Quick and dirty fix: pass ok_missing=true to mission::find to silence the error for this particular function call
Proper fix: go through the tiles in the OMT of the mission and remove references to its mission id

@physics-enthusiast physics-enthusiast marked this pull request as ready for review January 13, 2024 23:21
@Maleclypse Maleclypse merged commit d189811 into CleverRaven:master Jan 21, 2024
36 of 40 checks passed
@physics-enthusiast physics-enthusiast deleted the spawn-monsters-submap-fix branch January 21, 2024 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` json-styled JSON lint passed, label assigned by github actions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash after reaching failed/removd Sky Island Kill mission
2 participants