Uh oh!
There was an error while loading. Please reload this page.
Clean up deadlock regression test - #151
Conversation
- 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>
There was a problem hiding this comment.
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.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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>
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>
Move shared state (hookSignaled, workerInHook, testDone) from stack to heap via shared_ptr<State>. On timeout the test thread is detached, so it must not reference stack variables that are destroyed when the test function returns. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
FAIL() only returns from the test function — gtest continues running. The detached deadlocked thread corrupts process state, causing segfaults during teardown on Linux. Use quick_exit(1) instead since the process is unrecoverable. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The hook fires on every blocking_tick wait, not just the first. After the worker processes the destructor's no-op wake-up and loops back, the hook fired again, sleeping 200ms with no pending push to wake the worker afterward — causing a real deadlock in the test itself. Return early after the first invocation so subsequent wait() calls are not delayed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
With quick_exit(1) on timeout, the process terminates immediately so stack variables are never destroyed while the detached thread runs. No need for shared_ptr heap allocation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The segfault was caused by the hook sleeping on every invocation, not by FAIL() being unsafe. With the hook fixed to only fire once, the timeout path should never be reached. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
bghgary
left a comment
There was a problem hiding this comment.
Synchronous review comments.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Expanded comment to clarify that the sleep is not truly deterministic and explain its purpose: hold the mutex long enough for runtime.reset() to reach push() while the mutex is still held. The test_hooks::dispatcher namespace suggestion is noted as a follow-up for arcana.cpp. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Clean up the deadlock regression test from #147.
Changes
wait()callsboolfor hookSignaled (only accessed by worker thread)Dependency Updates
ARCANA_TESTING_HOOKStoARCANA_TEST_HOOKS, hooks moved toarcana::test_hooks::blocking_concurrent_queuenamespace)Verification