From dcf09c0c634b8b8e8e8555b1e6dcad65cd4c80ea Mon Sep 17 00:00:00 2001 From: Eric Beuque Date: Mon, 17 Feb 2025 17:45:51 +0100 Subject: [PATCH] Fix bad signal restoration which can cause infinite loop This fix the FatalSignalHandler destructor to restore properly the signal handler which cause an infinite loop when a signal is emitted like SIGABRT or SIGINT and when we are using two QTest object in same program. Fixes: QTBUG-132121 Pick-to: 6.8 6.5 Change-Id: Ie9476e1ff9c0f29c3e35ae6dff565fab4a77ba86 Reviewed-by: Thiago Macieira (cherry picked from commit 50d1a22e5c6361e7c1ef09432b2a151eee3e6114) Reviewed-by: Qt Cherry-pick Bot --- src/testlib/qtestcrashhandler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/testlib/qtestcrashhandler.cpp b/src/testlib/qtestcrashhandler.cpp index bc4e1629dd9..ab4e5f4a656 100644 --- a/src/testlib/qtestcrashhandler.cpp +++ b/src/testlib/qtestcrashhandler.cpp @@ -548,10 +548,10 @@ FatalSignalHandler::~FatalSignalHandler() for (size_t i = 0; i < fatalSignals.size(); ++i) { struct sigaction &act = oldActions()[i]; - if (act.sa_flags == 0 && act.sa_handler == SIG_DFL) - continue; // Already the default if (sigaction(fatalSignals[i], nullptr, &action)) continue; // Failed to query present handler + if (action.sa_flags == 0 && action.sa_handler == SIG_DFL) + continue; // Already the default if (isOurs(action)) sigaction(fatalSignals[i], &act, nullptr); }