From 7f0c2de9ad2f329319ea693493cf2442ef572b8b Mon Sep 17 00:00:00 2001 From: Emily Deng Date: Thu, 21 Nov 2024 17:53:03 +0800 Subject: [PATCH] kfdtest: Fix the dead lock SignalHandling The issue arises in the CatchSignal function, which attempts to write to the standard error stream upon receiving a signal. However, the standard error stream may already be locked at this point, as the parent process also attempts to write to the standard error stream after mapping the GPU memory. This leads to a deadlock, with the program waiting for the release of the lock on the standard error stream. Signed-off-by: Emily Deng Change-Id: Ie69354f4342b96ffe1f2a87f655687da1cbee4b9 [ROCm/ROCR-Runtime commit: c8031f2a69c56c0696d2158fc36164bc6786db91] --- .../libhsakmt/tests/kfdtest/src/KFDMemoryTest.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/projects/rocr-runtime/libhsakmt/tests/kfdtest/src/KFDMemoryTest.cpp b/projects/rocr-runtime/libhsakmt/tests/kfdtest/src/KFDMemoryTest.cpp index cc7e06646a..d485bd1207 100644 --- a/projects/rocr-runtime/libhsakmt/tests/kfdtest/src/KFDMemoryTest.cpp +++ b/projects/rocr-runtime/libhsakmt/tests/kfdtest/src/KFDMemoryTest.cpp @@ -1468,9 +1468,10 @@ TEST_F(KFDMemoryTest, PtraceAccessInvisibleVram) { TEST_END } +volatile int IntrSignalReceviced; + void CatchSignal(int IntrSignal) { - LOG() << "Interrupt Signal " << std::dec << IntrSignal - << " Received" << std::endl; + IntrSignalReceviced = IntrSignal; } TEST_F(KFDMemoryTest, SignalHandling) { @@ -1529,6 +1530,11 @@ TEST_F(KFDMemoryTest, SignalHandling) { // Parent process, just wait for the child to finish do { pid = waitpid(childPid, &childStatus, 0); + if (IntrSignalReceviced) { + LOG() << "Interrupt Signal " << std::dec << IntrSignalReceviced + << " Received" << std::endl; + IntrSignalReceviced = 0; + } } while(pid == -1 && errno == EINTR); EXPECT_EQ(childPid, pid); EXPECT_NE(0, WIFEXITED(childStatus));