[LTP] [PATCH] lib: fputs() in print_result() is not signal safe

Cyril Hrubis chrubis@suse.cz
Fri Feb 21 17:29:04 CET 2020


Hi!
> We have tests that use tst_res() from signal handler and current
> implementation leads to rare hangs if signal arrives in bad time:
>   main
>    tst_run_tcases
>     fork_testrun
>      testrun
>       run_tests
>        run
>         tst_res_ -> TINFO from main process
>          tst_vres_
>           print_result
>            fputs
>             __lll_lock_wait_private
>             <signal handler called>
>              tst_res_ -> TINFO from signal handler
>               tst_vres_
>                print_result
>                 fputs
>                  __lll_lock_wait_private -> HANGS
> 
> One example is timer_settime01, where we have TPASS from main process
> and TINFO as response to SIGALRM. SIGALRM happening immediately on older
> kernels might be a bug, but that is beside the point of this patch.

I guess that tst_res() wasn't even supposed to be signal-async-safe but
looking at the code I guess that this is the only change needed to make
it so.

Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list