Skip to content

Harden Binary Ninja controller lifecycle#526

Open
amattas wants to merge 1 commit into
binsync:mainfrom
amattas:pr/binja-controller-lifecycle
Open

Harden Binary Ninja controller lifecycle#526
amattas wants to merge 1 commit into
binsync:mainfrom
amattas:pr/binja-controller-lifecycle

Conversation

@amattas

@amattas amattas commented Jun 15, 2026

Copy link
Copy Markdown

Problem

The Binary Ninja plugin kept controllers in a defaultdict(BSController). That creates unbound controllers without an initialized Binary Ninja decompiler interface, and it makes sidebar/config flows fragile when Binary Ninja has no current view or when multiple BinaryViews are involved.

Failure modes this addresses:

  • Creating a sidebar can retrieve a controller that was not bound to the BinaryView.
  • Launching config with no current view can raise instead of no-oping.
  • Controllers are not centrally stopped/cleared during plugin lifecycle cleanup.

Solution

  • Replace implicit defaultdict controller creation with an explicit controller_for_bv() helper.
  • Create each controller with a BinjaInterface(bv=bv) so the decompiler interface is bound to the correct BinaryView from the start.
  • Make config launch a no-op when Binary Ninja has no active current view.
  • Add stop_controllers() to stop worker routines and clear controller state.
  • Add tests for per-view controller creation, no-current-view config launch, sidebar controller creation, and controller cleanup.

Verification

  • conda run -n ghidra python -m pytest tests -q --ignore=tests/test_angr_gui.py -> 20 passed, 1 warning
  • conda run -n ghidra python -m compileall -q binsync tests
  • git diff --check

Notes

This is Binary Ninja-specific lifecycle hardening and is independent of the Ghidra PRs.

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