diff options
author | Thiago Macieira <[email protected]> | 2024-09-19 13:05:35 -0700 |
---|---|---|
committer | Thiago Macieira <[email protected]> | 2024-09-25 11:15:32 -0700 |
commit | 731b1159f9da9d0a5f9871ceaef4b82b657b130c (patch) | |
tree | de5a450683b58b2328cdbc175059190e702b7e16 /src/testlib/qtestcrashhandler.cpp | |
parent | 0120d8ea1e49c61c2e218fe1eee952496ef3a0ee (diff) |
QTest::CrashHandler: allow debugging crashed tests on Linux+YAMA
The YAMA LSM by default[1] prevents attaching the debugger to any
process that isn't a child. Since our backtracer comes from a child
process instead (i.e., tracing the parent), we must grant explicit
permission. This also makes QTEST_PAUSE_ON_CRASH=1 work.
[1] https://codebrowser.dev/linux/linux/security/yama/yama_lsm.c.html#ptrace_scope
Pick-to: 6.8
Change-Id: Ic19d84a7a730c7f8fc0ffffd64e516447e4b1f35
Reviewed-by: Mitch Curtis <[email protected]>
Diffstat (limited to 'src/testlib/qtestcrashhandler.cpp')
-rw-r--r-- | src/testlib/qtestcrashhandler.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/testlib/qtestcrashhandler.cpp b/src/testlib/qtestcrashhandler.cpp index aabac1c4663..42a715ff865 100644 --- a/src/testlib/qtestcrashhandler.cpp +++ b/src/testlib/qtestcrashhandler.cpp @@ -61,6 +61,7 @@ #include <stdlib.h> #if defined(Q_OS_LINUX) +#include <sys/prctl.h> #include <sys/types.h> #include <fcntl.h> #endif @@ -327,6 +328,11 @@ void generateStackTrace() if (debugger == None || alreadyDebugging()) return; +# if defined(Q_OS_LINUX) && defined(PR_SET_PTRACER) + // allow ourselves to be debugged + (void) prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY); +# endif + # if defined(Q_OS_UNIX) && !defined(Q_OS_WASM) && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_VXWORKS) writeToStderr("\n=== Stack trace ===\n"); |