managers: remove module from list before calling disable() - #37
Open
0xrlawrence wants to merge 1 commit into
Open
0xrlawrence wants to merge 1 commit into
0xrlawrence wants to merge 1 commit into
Conversation
_removeModule invoked module.disable() (via excessivelySafeCall) before removing the module from the modules linked list. HookManager._removeHook uses the opposite order: it delists first, then calls disable(). Because a module's disable() may check its own registration (e.g. via isModule), delisting first lets such implementations complete their teardown. Reorder _removeModule to match _removeHook. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Summary
ModuleManager._removeModulecallsdisable()on the module first and removes it from the modules linked list afterwards:HookManager._removeHookuses the opposite order — it delists first and then callsdisable(). A module'sdisable()may check whether it is still registered (for example viaisModule), so removing it from the list before the call lets those implementations observe themselves as already removed and complete their teardown. Thedisable()call is made throughexcessivelySafeCall, so its outcome is not inspected here.This reorders
_removeModuleto delist before callingdisable(), aligning it with_removeHook.Change
Move
_modulesLinkedList().remove(module)above theexcessivelySafeCall(... disable ...). No change for modules whosedisable()does not depend on registration state.Security note. While reviewing these contracts I also came across a couple of more sensitive, design-level observations that I don't think belong in a public thread. If a maintainer would like to discuss them privately, I'd be glad to share — please reach out on GitHub (@0xrlawrence), or open a private security advisory on this repository and add me. Happy to coordinate on disclosure and fixes.
🤖 Generated with Claude Code