SIGSEGV when called sem_init() with gdb.

Oreste Bernardi
Tue Dec 10 07:15:00 GMT 2002

Dear, all

#include <semaphore.h>
int main () {
int p;
sem_t sem;
int i=0,d;
//sem=(sem_t)NULL; //With this There isn't any problem
sem_init (&sem,0,1);
sem_post (&sem);
return i;

cygwin 1.3.17-1
gcc  3.2-3
gdb  20010428-3

When executing this source code with gdb I get an SIGSEGV signal  when
sem_init() function is called.
If I continue on, program works fine.
If program is not executed from gdb, it works without any error.
If I initialize it with NULL, I don't get any error.

I think that is the same behavior as described by following mail:
Is this true ?

To avoid annoying gdb error message, is my solution ("sem=(sem_t)NULL")
reliable and portable ?

Best Regards
Oreste Bernardi

Unsubscribe info:
Bug reporting:

More information about the Cygwin mailing list