Date: Fri, 16 May 2008 21:14:11 +0200 (CEST) From: Oliver Fromme <olli@lurza.secnetix.de> To: freebsd-hackers@FreeBSD.ORG, deathjestr@gmail.com, jille@quis.cx Subject: Re: Trying (not) to crash with libpthread (6.3-RELEASE) Message-ID: <200805161914.m4GJEBSD053921@lurza.secnetix.de> In-Reply-To: <44b564930805160955r76d6861fo1949c7f4d5b71ca5@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Mike <deathjestr@gmail.com> wrote:
> Jille Timmermans wrote:
> > void
> > sigcatcher(int sig) {
> > printf("[%p] signal %d\n", pthread_self(), sig);
> > printf("Test (probably) succeeded\n");
> > fflush(NULL);
> > success=1;
> > exit(0);
> > }
>
> Take a look at the man page for sigaction(2). Here's an excerpt:
>
> "All functions not in the above lists are considered to be unsafe with
> respect to signals. That is to say, the behaviour of such functions when
> called from a signal handler is undefined. In general though, signal
> handlers should do little more than set a flag; most other actions are
> not safe."
Additionally, the "success" variable should be
declared as "volatile sig_atomic_t".
By the way, this code ...
> > char *x=malloc(1);
> > [...]
> > x[666]=0;
.. does not necessarily cause a SIGSEGV. It may do so,
but it is not guaranteed. It may as well write into a
random memory area that happens to belong to your process,
too. The result is undefined, i.e. it could be anything.
If you need to send a SIGSEGV to yourself reliably, the
best way is to kill(getpid(), SIGSEGV).
Best regards
Oliver
--
Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606, Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758, Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart
FreeBSD-Dienstleistungen, -Produkte und mehr: http://www.secnetix.de/bsd
"File names are infinite in length, where infinity is set to 255 characters."
-- Peter Collinson, "The Unix File System"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200805161914.m4GJEBSD053921>
