mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-10 17:36:11 +00:00
drmtest: Avoid wrong PID/TID after clone races
Various C library implementations have various races with regards to caching getpid() or TID inside pthread_kill() implementations. For example see clone(2) glibc man page and pthread_kill Bionic C library source. Work around that by making sure correct PID/TGID and TID values are retrieved from the kernel when re-raising the signal. It can be delivered immediately after the clone system call while C library cached copies have not yet been updated. Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
parent
4f990f3ad2
commit
139c72f38a
@ -43,6 +43,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/syscall.h>
|
||||
|
||||
#include "drmtest.h"
|
||||
#include "i915_drm.h"
|
||||
@ -1479,6 +1481,8 @@ static void igt_atexit_handler(void)
|
||||
|
||||
static void fatal_sig_handler(int sig)
|
||||
{
|
||||
pid_t pid, tid;
|
||||
|
||||
restore_all_sig_handler();
|
||||
|
||||
/*
|
||||
@ -1487,7 +1491,11 @@ static void fatal_sig_handler(int sig)
|
||||
*/
|
||||
call_exit_handlers(sig);
|
||||
|
||||
raise(sig);
|
||||
/* Workaround cached PID and TID races on glibc and Bionic libc. */
|
||||
pid = syscall(SYS_getpid);
|
||||
tid = syscall(SYS_gettid);
|
||||
|
||||
syscall(SYS_tgkill, pid, tid, sig);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user