This is the mail archive of the
mailing list for the glibc project.
Re: determine whether code is running in a signal handler context
On 27/11/2017 10:51, Florian Weimer wrote:
> On 11/27/2017 01:50 PM, Yubin Ruan wrote:
>> 2017-11-27 19:55 GMT+08:00 Florian Weimer <firstname.lastname@example.org>:
>>> On 11/27/2017 09:42 AM, Yubin Ruan wrote:
>>>> Still remember this thread? It turn out that determining whether or not
>>>> are currently in a signal handler is trivial with libunwind:
>>> This is incorrect. libunwind (or any other unwinder) relies on information
>>> which is not always available.
>> what information?
> Unwind tables. A correct stack pointer or frame pointer.
Just check libunwind usage and implementation for unw_is_signal_frame and
you will notice a lot of ad-hoc and heuristics which may or not fail
depending of the underlying system and binary. Also unw_is_signal_frame
is not implemented for all architectures or for all OS, it is hardly a
portable interface to rely on.