Hi,

It's possible to trigger a deadlock in winpthreads'
pthread_cond_signal() when using the pthread_cond_signal() call
outside of a pthread_mutex_lock()/pthread_mutex_unlock() region. This
problem happens under Windows 2012 R2 with winpthreads-5.0.3
(Cygwin64) and winpthreads-7.2.0 (standalone) and also on Fedora 26
under wine-3.2-2.fc26.x86_64 using
mingw64-winpthreads-static-5.0.2-1.fc26.noarch. The problem was
originally seen by a Windows user of the fio project (see
https://www.spinics.net/lists/fio/msg06772.html ) but a standalone
program that reproduces the problem is attached. The problem is
intermittent (so you may need to up the threads/iterations or run the
program multiple times) but a backtrace of the thread with the hang
looks like this:

(gdb) bt
#0  0x00007ff9e03d079a in ntdll!ZwWaitForSingleObject ()
   from C:\windows\SYSTEM32\ntdll.dll
#1  0x00007ff9dd801118 in WaitForSingleObjectEx ()
   from C:\windows\system32\KernelBase.dll
#2  0x000000000040346c in do_sema_b_wait_intern (sema=sema@entry=0x30,
    nointerrupt=nointerrupt@entry=1, timeout=timeout@entry=4294967295)
    at /usr/src/debug/mingw64-x86_64-winpthreads-5.0.3-1/src/cond.c:601
#3  0x00000000004035ae in do_sema_b_wait (sema=0x30, nointerrupt=1,
    timeout=4294967295, cs=0x6f98f0, val=0x6f9918)
    at /usr/src/debug/mingw64-x86_64-winpthreads-5.0.3-1/src/cond.c:584
#4  0x000000000040383f in pthread_cond_signal (c=<optimized out>)
    at /usr/src/debug/mingw64-x86_64-winpthreads-5.0.3-1/src/cond.c:327
#5  0x0000000000401681 in mutex_up (mutex=0x23fde0) at signalhang.c:62
#6  contend_lock_thread (data=0x6f9bd0) at signalhang.c:77
#7  0x0000000000405314 in pthread_create_wrapper (args=0x0)
    at /usr/src/debug/mingw64-x86_64-winpthreads-5.0.3-1/src/thread.c:1492
#8  0x00007ff9dfd60b13 in msvcrt!_strupr ()
   from C:\windows\system32\msvcrt.dll
#9  0x00007ff9dfd60bcd in msvcrt!_endthreadex ()
   from C:\windows\system32\msvcrt.dll
#10 0x00007ff9df6f13d2 in KERNEL32!BaseThreadInitThunk ()
   from C:\windows\system32\kernel32.dll
#11 0x00007ff9e03554f4 in ntdll!RtlUserThreadStart ()
   from C:\windows\SYSTEM32\ntdll.dll
#12 0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

The hang never happens when using glibc's pthread implementation under Linux.

-- 
Sitsofe | http://sucs.org/~sits/
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to