This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Cygwin 1.7 pthread hides segmentation fault


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 http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]