From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH V3] syscalls/timer_settime01: Make sure the timer fires
Date: Wed, 15 Jul 2020 10:53:14 +0200 [thread overview]
Message-ID: <20200715085314.GA7741@yuki.lan> (raw)
In-Reply-To: <20200715023642.jlldqjr7phru7ojj@vireshk-i7>
Hi!
> > Pushed with minor changes, thanks.
> >
> > Among other fixes I've moved the signal check from the signal handler to
> > the clear_signal() function, since the tst_res() function is not
> > signal-async-safe...
>
> What does that mean ? I remember that I added it there in
> clear_signal() first, but then I tried to print the stuff (forcefully)
> from sighandler() and it worked without any issues and so I did that.
Calling printf() from signal handler is not safe, which tst_res() does.
It will work fine 99% of the cases and this is the reason most people do
it anyways. One of the failure modes is the malloc arena lock. Printf
may allocate temporary buffer so if the signal comes when the process is
in the malloc code the process will hang forewer because it will try to
acquire a lock that has been locked before we jumped into the signal
handler, but there is probably more. It usually gets triggered on
stranger architectures, x86 is quite forgiving in this regard.
Signal handlers are generally tricky and there is a list of functions
that carefuly avoid messing with any global state and can be safely used
from withing a signal handler (man 7 signal-safety) anything else is,
unlikely to fail, but still potential hazard.
Generally the safest approach to signal handlers is to set a variable
and exit, which is what I usually do in tests...
--
Cyril Hrubis
chrubis@suse.cz
next prev parent reply other threads:[~2020-07-15 8:53 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-29 11:43 [LTP] [PATCH 1/2] syscalls/timer_settime01: Improve print messages Viresh Kumar
2020-06-29 11:43 ` [LTP] [PATCH 2/2] syscalls/timer_settime01: Make sure the timer fires Viresh Kumar
2020-06-29 12:05 ` Arnd Bergmann
2020-06-29 12:13 ` Cyril Hrubis
2020-06-30 2:27 ` Viresh Kumar
2020-06-30 2:36 ` [LTP] [PATCH V1.1 " Viresh Kumar
2020-07-02 13:34 ` [LTP] [PATCH 1/2] syscalls/timer_settime01: Improve print messages Cyril Hrubis
2020-07-03 2:22 ` Viresh Kumar
2020-07-03 2:39 ` [LTP] [PATCH V2] syscalls/timer_settime01: Make sure the timer fires Viresh Kumar
2020-07-07 15:02 ` Cyril Hrubis
2020-07-08 10:31 ` [LTP] [PATCH V3] " Viresh Kumar
2020-07-14 14:28 ` Cyril Hrubis
2020-07-15 2:36 ` Viresh Kumar
2020-07-15 8:53 ` Cyril Hrubis [this message]
2020-07-23 2:39 ` Yang Xu
2020-07-24 3:37 ` Viresh Kumar
2020-07-24 5:07 ` Yang Xu
2020-07-24 10:18 ` Viresh Kumar
2020-07-24 10:27 ` Yang Xu
2020-07-24 13:29 ` Cyril Hrubis
2020-07-24 15:01 ` Yang Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200715085314.GA7741@yuki.lan \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox