Skip to content

managers: remove module from list before calling disable() - #37

Open
0xrlawrence wants to merge 1 commit into
Abstract-Foundation:mainfrom
0xrlawrence:refactor/module-removal-order
Open

0xrlawrence wants to merge 1 commit into
Abstract-Foundation:mainfrom
0xrlawrence:refactor/module-removal-order

Conversation

@0xrlawrence

@0xrlawrence 0xrlawrence commented Sep 3, 2026

Copy link
Copy Markdown

Summary

ModuleManager._removeModule calls disable() on the module first and removes it from the modules linked list afterwards:

module.excessivelySafeCall(..., IInitable.disable.selector);
_modulesLinkedList().remove(module);

HookManager._removeHook uses the opposite order — it delists first and then calls disable(). A module's disable() may check whether it is still registered (for example via isModule), so removing it from the list before the call lets those implementations observe themselves as already removed and complete their teardown. The disable() call is made through excessivelySafeCall, so its outcome is not inspected here.

This reorders _removeModule to delist before calling disable(), aligning it with _removeHook.

Change

Move _modulesLinkedList().remove(module) above the excessivelySafeCall(... disable ...). No change for modules whose disable() 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

_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>
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

Successfully merging this pull request may close these issues.

1 participant