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 <mitch.curtis@qt.io>
This commit is contained in:
parent
0120d8ea1e
commit
731b1159f9
@ -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");
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user