Fix member destruction order in SimulationRunner#3460
Closed
taylorhoward92 wants to merge 2 commits intogazebosim:mainfrom
Closed
Fix member destruction order in SimulationRunner#3460taylorhoward92 wants to merge 2 commits intogazebosim:mainfrom
taylorhoward92 wants to merge 2 commits intogazebosim:mainfrom
Conversation
dcddb9a to
34eda28
Compare
systemMgr must be destroyed before eventMgr and entityCompMgr because systems hold references to both managers. Rather than reordering member declarations (which changes class layout and breaks Windows CI), explicitly reset systemMgr in the destructor. The destructor body runs before implicit member destruction, so systems are cleanly stopped while both managers are still alive. Signed-off-by: Taylor Howard <taylorhoward@me.com> Generated-by: Claude Code Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
34eda28 to
66b8eab
Compare
Contributor
Author
|
This change is causing issues on Windows and was just an additional safety net on top of the change in #3459. Closing for now. |
Contributor
|
Thanks for being a good citizen about this! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🦟 Bug fix
Summary
systemMgrwas declared beforeeventMgrandentityCompMgrinSimulationRunner.hh. C++ destroys members in reverse declaration order, sosystemMgrwas being destroyed after those managers. However, systems hold references to both theEventManagerandEntityComponentManager, so they must be stopped and destroyed first to avoid use-after-free on shutdown.Changes
Move the
systemMgrdeclaration aftereventMgrandentityCompMgrso that it is destroyed first. The existing comments acknowledged this requirement ("must be before EntityComponentManager") but the declaration order was incorrect — "before" in the comment meant "destroyed before", but in C++ that requires declaring after.Checklist
codecheckpassed (See contributing)Generated-by: Claude Code
Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-byandGenerated-bymessages.