Skip to content

Clean up deadlock regression test#151

Open
bghgary wants to merge 3 commits intoBabylonJS:mainfrom
bghgary:fix/deadlock-test-cleanup
Open

Clean up deadlock regression test#151
bghgary wants to merge 3 commits intoBabylonJS:mainfrom
bghgary:fix/deadlock-test-cleanup

Conversation

@bghgary
Copy link
Copy Markdown
Contributor

@bghgary bghgary commented Apr 9, 2026

Clean up the deadlock regression test from #147.

Changes

  • Run entire test on a separate thread so gtest can detect deadlock via timeout without hanging the process
  • Install hook after initialization instead of using hookEnabled flag
  • Use plain bool for hookSignaled (only accessed by worker thread)
  • Move unique_ptr into test thread (single owner, natural create/destroy lifecycle)
  • Update comments and flow diagram to match code

Verified locally: passes with fix, detects deadlock with old destructor, exits cleanly in both cases.

- Run entire test on a separate thread so gtest can detect deadlock
  via timeout without hanging the process
- Install hook after initialization instead of using enable flag
- Use plain bool for hookSignaled (single-thread access)
- Move unique_ptr into test thread (single owner)
- Update comments and flow diagram to match code

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 9, 2026 17:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the AppRuntime destructor deadlock regression test (originally added in #147) to make deadlock detection reliable by letting the gtest thread time out while the destructor runs on a separate worker thread.

Changes:

  • Move the runtime lifecycle (create → init → hook → destroy) into a dedicated thread so the main test thread can detect deadlock via timeout.
  • Install the arcana before-wait hook after initialization and simplify hook signaling state.
  • Update test comments/flow diagram to match the new control flow.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

bghgary added a commit to bghgary/JsRuntimeHost that referenced this pull request Apr 9, 2026
Reverts the deadlock fix to demonstrate the test detects it.
Test updated with cleanup from BabylonJS#151.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
bghgary and others added 2 commits April 9, 2026 13:36
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Bump arcana.cpp GIT_TAG to b9bf9d85fce37d5fc9dbfc4a4dc5e1531bee215a
which renames ARCANA_TESTING_HOOKS to ARCANA_TEST_HOOKS and moves hooks
to arcana::test_hooks::blocking_concurrent_queue namespace.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.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.

2 participants