summaryrefslogtreecommitdiffstats
path: root/src/testlib/qtestcase.cpp
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2022-01-19 12:45:37 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2022-02-09 18:19:57 +0100
commit985f0e9ca5905af7791f39fddd005f0c9f8fe081 (patch)
treed2bfeaa855d3802d3ac264a2adccceb9d2ced2d5 /src/testlib/qtestcase.cpp
parent13fa00519d684ddc1779845cebbd6cec552f8f1c (diff)
macOS: Don't print stack trace via lldb on test failure if SIP prevents it
If the CSR_ALLOW_UNRESTRICTED_FS bit of System Integrity Protection (SIP) is enabled lldb will fail to print a valid stack trace when launched from the crashed process, and might also resulting in hanging or crashing the parent process (Terminal e.g.): https://github.com/llvm/llvm-project/issues/53254 We detect this situation and avoid printing a stack trace if so. Pick-to: 6.3 6.2 Change-Id: Iad8cab5fcdc545d810ca4d4e985aefc0988d0234 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/testlib/qtestcase.cpp')
-rw-r--r--src/testlib/qtestcase.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index 673605307f..ee94cdde44 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -212,7 +212,14 @@ static void stackTrace()
if (debuggerPresent() || hasSystemCrashReporter())
return;
-#if defined(Q_OS_LINUX) || (defined(Q_OS_MACOS) && !defined(Q_PROCESSOR_ARM_64))
+#if defined(Q_OS_LINUX) || defined(Q_OS_MACOS)
+
+#if defined(Q_OS_MACOS)
+ #define CSR_ALLOW_UNRESTRICTED_FS (1 << 1)
+ std::optional<uint32_t> sipConfiguration = qt_mac_sipConfiguration();
+ if (!sipConfiguration || !(*sipConfiguration & CSR_ALLOW_UNRESTRICTED_FS))
+ return; // LLDB will fail to provide a valid stack trace
+#endif
const int msecsFunctionTime = qRound(QTestLog::msecsFunctionTime());
const int msecsTotalTime = qRound(QTestLog::msecsTotalTime());