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

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Fri Jun 16 09:53:19 UTC 2023


On Mon, Jun 12, 2023 at 07:19:08PM +0200, Kamil Konieczny wrote:
> 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.
> 

I'm sorry you had to wait so long for the review. Change looks safe
for me, I mean exit_subtest() won't try to n-time reinitialize
allocator and other global data.

Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>

--
Zbigniew


> 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