[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: undefined behavior in closeout, aggravated by libsigsegv
From: |
Bruno Haible |
Subject: |
Re: undefined behavior in closeout, aggravated by libsigsegv |
Date: |
Fri, 11 Dec 2009 14:01:28 +0100 |
User-agent: |
KMail/1.9.9 |
Hi Eric,
Eric Blake wrote on 2009-11-23:
> The particular m4 bug that sparked this thread had three cooperating
> causes - fix any one of the three, and the crash goes away (so, in true
> open source fashion, I fixed all three of the problems, through three
> different projects). newlib's fflush used to blindly grab a lock (causing
> a fault if the lock was bogus), but now checks for a valid file first.
> Gnulib's error was calling fflush(stdout) without checking if it was
> valid. And libsigsegv was intercepting the fault handling before cygwin
> had a chance to ignore it.
> http://cygwin.com/ml/cygwin-talk/2009-q3/msg00021.html
>
> But since cygwin 1.5 did not experience the internal fault, and it has
> already been patched in current CVS cygwin 1.7, the only way to reproduce
> the bug that sparked this thread is to revert to an older snapshot of
> cygwin 1.7.
Oh, I see. This explains all the confusion. Thanks.
> Here's a relatively simple example. ...
>
> $ cat foo.c
> #include <unistd.h>
> #include <fcntl.h>
> #include <string.h>
> #include <errno.h>
> #include <stdio.h>
> #include <pthread.h>
> #include <stdlib.h>
> #include <sigsegv.h>
>
> int
> handler (void *addr, int bad)
> {
> exit (2);
> }
>
> int main (int argc, char **argv)
> {
> pthread_attr_t a;
> memset (&a, 1, sizeof a);
> pthread_attr_init (&a);
>
> if (1 < argc)
> sigsegv_install_handler (handler);
> pthread_attr_t b;
> memset (&b, 1, sizeof b);
> pthread_attr_init (&b);
>
> return 0;
> }
> $ gcc -o foo -Wall -g foo.c -lsigsegv
> $ ./foo; echo $?
> 0
> $ ./foo 1; echo $?
> 2
I reproduce. So, indeed, libsigsegv must let cygwin have a first look at
every fault.
> Search for verifyable_object_isvalid in:
>
> http://cygwin.com/cgi-bin/cvsweb.cgi/src/winsup/cygwin/thread.cc?rev=1.216&content-type=text/x-cvsweb-markup&cvsroot=src
Oh, funny code: san sebastian, san andreas, ... :-)
> Given that I have proven a case where cygwin relies on internal fault
> handling
> for more than just EFAULT, and that correct program behavior is broken if
> libsigsegv built without --enable-EFAULT interferes, how about this patch?
I'm changing libsigsegv to enable --enable-EFAULT by default. Then, it does not
make much sense any more to document this option: It would makes sense on the
Hurd, but it's not actually implemented for the Hurd.
Bruno
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: undefined behavior in closeout, aggravated by libsigsegv,
Bruno Haible <=