Skip to content

Guard g_debuggerControllers for concurrent access#1017

Merged
xusheng6 merged 1 commit intodevfrom
test_guard_controller_list
Mar 18, 2026
Merged

Guard g_debuggerControllers for concurrent access#1017
xusheng6 merged 1 commit intodevfrom
test_guard_controller_list

Conversation

@xusheng6
Copy link
Copy Markdown
Member

Summary

  • Replace raw g_debuggerControllers pointer + manual realloc/placement-new with a function-local static std::vector returned by GetControllers(), avoiding the static initialization order fiasco
  • Add std::mutex g_controllerMutex with lock_guard in all 6 accessor functions (GetController, DeleteController, ControllerExists for both BinaryViewRef and FileMetadataRef overloads) to prevent data races on concurrent access

Fix #1016

Test plan

  • Build the project and verify no compilation errors
  • Open multiple debug sessions concurrently and verify no crashes
  • Close debug sessions and verify controllers are cleaned up properly

🤖 Generated with Claude Code

@xusheng6 xusheng6 force-pushed the test_guard_controller_list branch from 1acd8c4 to ea7751d Compare March 18, 2026 04:49
Replace the raw pointer + manual realloc/placement-new with a
heap-allocated ControllerState struct (mutex + vector), accessed via
a function-local static pointer. This fixes potential data races when
multiple threads call GetController, DeleteController, or
ControllerExists concurrently.

The ControllerState is intentionally leaked (never freed) so the mutex
remains valid even during late cleanup -- e.g., Python's GC calling
Destroy() via FFI after static destruction has begun.

Fix #1016

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@xusheng6 xusheng6 force-pushed the test_guard_controller_list branch from ea7751d to 17c370c Compare March 18, 2026 04:54
@xusheng6 xusheng6 merged commit c7e0cf1 into dev Mar 18, 2026
1 check passed
@xusheng6 xusheng6 deleted the test_guard_controller_list branch March 18, 2026 07:13
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.

No guard on g_debuggerControllers for concurrent access

1 participant