From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Andreas Glatz <AndreasGlatz@domain.hid>
Cc: "xenomai@xenomai.org" <xenomai@xenomai.org>
Subject: Re: [Xenomai-help] Calling native API in user-space signal handler
Date: Fri, 15 Jan 2010 19:24:04 +0100 [thread overview]
Message-ID: <4B50B2C4.1020904@domain.hid> (raw)
In-Reply-To: <245373446233674495BCA5CA2FC1EB1733A1170AF7@domain.hid>
Andreas Glatz wrote:
> Hi,
>
> I wrote my on SIGSEGV signal handler which gathers information about
> the fault and passes that info to a separate process for
> post-processing.
>
> I'm wondering if it's always save to call native API functions in a
> signal handler?
>
> (As according to man 7 signal', it's just save to call a subset of
> Glibc functions from within a signal handler.)
It is definitely not safe to assume that you may call any function in a
signal handler.
Calling pthread_mutex_lock in a signal handler can cause a multithreaded
application to deadlock for instance (if the preempted code was also in
the middle of a pthread_mutex_lock), so that calling the apparently
inocuous printf might deadlock.
Now, for the Xenomai services. You can in fact call any function whose
implementation is in fact a simple syscall. If a function does more than
simply emitting a syscall, then all bets are off. And of course, we can
not guarantee you that a function which is emitting a syscall now will
not get more complicated in later releases.
Another safe solution is to use the "ptrace" syscall, the one used by
gdb, instead of installing a handler for SIGSEGV. Granted, this will
become a bit more completely, but should be more safe.
Or enable generation of core files.
--
Gilles.
next prev parent reply other threads:[~2010-01-15 18:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-15 14:47 [Xenomai-help] Calling native API in user-space signal handler Andreas Glatz
2010-01-15 18:24 ` Gilles Chanteperdrix [this message]
2010-01-15 18:59 ` Jan Kiszka
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=4B50B2C4.1020904@domain.hid \
--to=gilles.chanteperdrix@xenomai.org \
--cc=AndreasGlatz@domain.hid \
--cc=xenomai@xenomai.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.