pthread_testcancel() causes SEGV

Jason Tishler jason@tishler.net
Tue Aug 6 11:34:00 GMT 2002


I believe that I have found the root cause to the following:

    http://cygwin.com/ml/cygwin/2002-08/msg00381.html

It seems that pthread_testcancel() will SEGV when called in a non-main
thread or at least one driven by the SCM during service startup.  See
attached for a gdb backtrace.

The following CVS commit seems to be the likely culprit:

    http://cygwin.com/ml/cygwin-cvs/2002-q3/msg00033.html

which is consistent with the fact that 1.3.12 does not exhibit this
problem but snapshots and CVS do.

I annotated pthread::self() as follows:

    pthread *
    pthread::self ()
    {
      pthread *p = (pthread *) TlsGetValue (MT_INTERFACE->thread_self_dwTlsIndex);
      debug_printf ("pthread::self: p = %x, i = %ld", p, MT_INTERFACE->thread_self_dwTlsIndex);
      return p;
    }

When starting ipc-daemon, I get the following:

    87 3097903 [unknown (0xD8C)] ipc-daemon 920 pthread::self: pthread::self: p = 0, i = 4

instead of something like the following (from a non-SCM test case):

    85  121609 [main] open 2504 pthread::self: pthread::self: p = 610CD61C, i = 4

Note that p is 0 in the former and non-zero in the latter.

Unfortunately, I'm not sure how to fix this problem.  Any help will be
greatly appreciated.

Thanks,
Jason
-------------- next part --------------
(gdb) attach 2172
Attaching to program `/home/jt/src/cygipc/ipc-daemon.exe', process 2172
[Switching to thread 2172.0xb4c]
(gdb) c
Continuing.

Program received signal SIGSEGV, Segmentation fault.
[Switching to thread 2172.0x2a4]
pthread::testcancel (this=0x0) at ../../../../src/winsup/cygwin/thread.cc:682
682       if (cancelstate == PTHREAD_CANCEL_DISABLE)
Current language:  auto; currently c++

(gdb) bt
#0  pthread::testcancel (this=0x0)
    at ../../../../src/winsup/cygwin/thread.cc:682
#1  0x6104b8cc in pthread_testcancel ()
    at ../../../../src/winsup/cygwin/pthread.cc:443
#2  0x61040d6d in getpwuid32 (uid=18)
    at ../../../../src/winsup/cygwin/passwd.cc:252
#3  0x61055370 in is_grp_member (uid=18, gid=18)
    at ../../../../src/winsup/cygwin/sec_helper.cc:262
#4  0x6105b0a8 in alloc_sd (uid=18, gid=18, attribute=438, sd_ret=0x2043ea5c, 
    sd_size_ret=0x2043ea58) at ../../../../src/winsup/cygwin/security.cc:1655
#5  0x6105b7fe in set_security_attribute (attribute=438, psa=0x2043fa94, 
    sd_buf=0x2043ea5c, sd_buf_size=4096)
    at ../../../../src/winsup/cygwin/security.cc:1797
#6  0x610139f7 in fhandler_base::open (this=0x61611468, pc=0x2043fb04, 
    flags=1049090, mode=438) at ../../../../src/winsup/cygwin/fhandler.cc:432
#7  0x6101aa3e in fhandler_disk_file::open (this=0x61611468, 
    real_path=0x2043fb04, flags=514, mode=438)
    at ../../../../src/winsup/cygwin/fhandler_disk_file.cc:368
#8  0x6106be65 in _open (unix_path=0x401341 "/tmp/MultiFileSem", flags=514)
    at ../../../../src/winsup/cygwin/syscalls.cc:523
#9  0x00401861 in work_main () at ipc-daemon.c:251
#10 0x004026df in service_main (argc=1, argv=0x236840) at ipc-daemon.c:607
#11 0x77dc9571 in _system_dlls__ ()


More information about the Cygwin-developers mailing list