[igt-dev] [PATCH i-g-t] igt_core: Avoid exit_subtest in subthread

Kamil Konieczny kamil.konieczny at linux.intel.com
Mon Jun 12 17:19:08 UTC 2023


From: Petri Latvala <petri.latvala at intel.com>

If a thread crashes, the signal handler for SIGSEGV and pals try to
make the subtest fail and eventually longjmps out of the
subtest. Naturally this can cause multiple threads to yield subtest
results and other weirdness.

We already check for non-main-thread in igt_fail_assert() but the path
from a signal handler to subtest exit doesn't have such protection.

Cc: Petri Latvala <adrinael at adrinael.net>
Signed-off-by: Petri Latvala <petri.latvala at intel.com>
Signed-off-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>
---
 lib/igt_core.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/igt_core.c b/lib/igt_core.c
index cd9c2002d..1d8e3a6ee 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -1585,6 +1585,11 @@ __noreturn static void exit_subtest(const char *result)
 	struct timespec *thentime = in_dynamic_subtest ? &dynamic_subtest_time : &subtest_time;
 	jmp_buf *jmptarget = in_dynamic_subtest ? &igt_dynamic_jmpbuf : &igt_subtest_jmpbuf;
 
+	if (!igt_thread_is_main()) {
+		igt_thread_fail();
+		pthread_exit(NULL);
+	}
+
 	igt_gettime(&now);
 
 	if (test_multi_fork_child)
-- 
2.39.2



More information about the igt-dev mailing list