Cygwin 1.7 pthread hides segmentation fault

Eric Blake
Mon Jan 5 15:12:00 GMT 2015

On 01/04/2015 07:14 PM, Howard Guo wrote:
> It seems that segfaults go unreported using pthread and Cygwin 1.7.33-2.
> Here is a minimal code piece to reproduce:
> #include <pthread.h>
> void* thread_run(void* _) {
>         int *p = 0;
>         *p = 1;
>         return NULL;
> }
> int main(int argc, char** argv) {
>         pthread_t t1;
>         pthread_create(&t1, NULL, thread_run, NULL);
>         pthread_join(t1, NULL);
>         return 0;
> }
> Simply compiled with gcc -pthread, and the result executable returns 0
> without reporting segmentation fault.
> Could this be a bug?

Your program induces undefined behavior, and therefore, it could be
argued that the bug is in your program, not in cygwin.  But you are
correct that for optimal quality of implementation, we should be
delivering a SIGSEGV at the point where you assign through the bogus
pointer.  (I'm the libsigsegv maintainer, and the only way to PORTABLY
prove whether pthread is eating segfaults is to use mmap()/mprotect()
and cause a fault through a valid pointer; as faulting through the NULL
pointer is not portable.)

Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <>

More information about the Cygwin mailing list