summaryrefslogtreecommitdiffstats
path: root/src/corelib
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/corelib
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/corelib')
-rw-r--r--src/corelib/kernel/qcore_mac.mm33
-rw-r--r--src/corelib/kernel/qcore_mac_p.h1
2 files changed, 34 insertions, 0 deletions
diff --git a/src/corelib/kernel/qcore_mac.mm b/src/corelib/kernel/qcore_mac.mm
index 435b2a6150..162e55fa0d 100644
--- a/src/corelib/kernel/qcore_mac.mm
+++ b/src/corelib/kernel/qcore_mac.mm
@@ -58,6 +58,7 @@
#include <qdebug.h>
+#include "qendian.h"
#include "qhash.h"
#include "qpair.h"
#include "qmutex.h"
@@ -376,6 +377,38 @@ bool qt_mac_runningUnderRosetta()
return translated;
return false;
}
+
+std::optional<uint32_t> qt_mac_sipConfiguration()
+{
+ static auto configuration = []() -> std::optional<uint32_t> {
+ QIOType<io_registry_entry_t> nvram = IORegistryEntryFromPath(kIOMasterPortDefault, "IODeviceTree:/options");
+ if (!nvram) {
+ qWarning("Failed to locate NVRAM entry in IO registry");
+ return {};
+ }
+
+ QCFType<CFTypeRef> csrConfig = IORegistryEntryCreateCFProperty(nvram,
+ CFSTR("csr-active-config"), kCFAllocatorDefault, IOOptionBits{});
+ if (!csrConfig) {
+ qWarning("Failed to locate SIP config in NVRAM");
+ return {};
+ }
+
+ if (auto type = CFGetTypeID(csrConfig); type != CFDataGetTypeID()) {
+ qWarning() << "Unexpected SIP config type" << CFCopyTypeIDDescription(type);
+ return {};
+ }
+
+ QByteArray data = QByteArray::fromRawCFData(csrConfig.as<CFDataRef>());
+ if (data.size() != sizeof(uint32_t)) {
+ qWarning() << "Unexpected SIP config size" << data.size();
+ return {};
+ }
+
+ return qFromLittleEndian<uint32_t>(data.constData());
+ }();
+ return configuration;
+}
#endif
bool qt_apple_isApplicationExtension()
diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h
index 05bd5b7baa..0000f3b656 100644
--- a/src/corelib/kernel/qcore_mac_p.h
+++ b/src/corelib/kernel/qcore_mac_p.h
@@ -207,6 +207,7 @@ private:
#ifdef Q_OS_MACOS
Q_CORE_EXPORT bool qt_mac_applicationIsInDarkMode();
Q_CORE_EXPORT bool qt_mac_runningUnderRosetta();
+Q_CORE_EXPORT std::optional<uint32_t> qt_mac_sipConfiguration();
#endif
#ifndef QT_NO_DEBUG_STREAM