[rocprofiler-sdk] Fix signal-handler re-entrancy deadlock and enable app-abort testsadd a thread re-entrancy guard - #6875
Conversation
a1d28f9 to
299ce49
Compare
|
I see this is still in draft, but just wanted to flag that #6717 takes a broader approach to redesigning rocprofv3 signal handling. |
Thanks for the heads up! I agree there's overlap. #6717 reworks the whole handler to run finalization on a worker thread, which would address the same re-entrancy root cause and make this thread_local guard unnecessary. My PR was intended as a minimal fix :) I believe if #6717 can be merged, it will fix the app-abort flakiness as well! |



Motivation
The
rocprofv3-test-app-abortintegration tests (4 tests) were disabled unconditionally as "currently unstable". The instability was a real deadlock in rocprofv3's abort signal handler that caused the profiled process to hang on every abort. This PR fixes that deadlock and re-enables the tests.Technical Details
Root cause: rocprofv3 installs its signal handler before HSA does, so when HSA later calls
sigaction()it receives rocprofv3's handler as its "previous" handler. On an abort signal,rocprofv3_error_signal_handlerfinalizes output and invokes the chained HSA handler, which calls back the previous handler (rocprofv3's), re-entering the handler on the same thread while still insidestd::call_once. Recursive use ofstd::once_flagdeadlocks, so the process hangs and CTest times out. (SA_RESETHANDdoesn't help — the re-entry is a direct call, not a fresh signal delivery.)Fix:
source/lib/rocprofiler-sdk-tool/tool.cpp: add athread_localre-entrancy guard at handler entry that breaks the chain loop and terminates instead of recursing intocall_once. Preserves cross-threadcall_oncesemantics and is async-signal-safe.tests/rocprofv3/aborted-app/CMakeLists.txt: remove the unconditionalIS_DISABLED ON(still disabled under ThreadSanitizer).JIRA ID
Resolves AIROCVAL-48
Test Plan
Built for gfx942 (MI300X, ROCm 7.2) and ran the app-abort tests under multiple conditions:
ctest -R app-abort(execute + 3 validate steps).ctest --repeat until-fail:50under heavy CPU contention (load ~205).Test Result
100% pass; the execute step completes in ~1s (previously a 45s hang). Zero hangs across all runs and no leftover/spinning processes. The guard also correctly handled an induced
SIGABRTloop-back during stress, terminating cleanly instead of deadlocking.Submission Checklist