simple multithread program fails on Cygwin, succeeds on Linux

Bruno Haible bruno@clisp.org
Mon Aug 10 10:13:00 GMT 2009


Hi,

The attached test program for pthread_once uses the following basic POSIX
threads functions:
  pthread_create
  pthread_join
  pthread_mutex_init
  pthread_mutex_lock
  pthread_mutex_unlock
  pthread_once
  pthread_rwlock_init
  pthread_rwlock_rdlock
  pthread_rwlock_unlock
  pthread_rwlock_wrlock

On Linux with glibc 2.8:
  $ gcc bug.c -O -Wall -lpthread -o bug
  $ ./bug
  Starting test_once ... OK
The test completes in about 4 seconds.

On Cygwin 1.5.25(0.156/4/2):
  $ gcc bug.c -O -Wall -o bug.exe         
  $ ./bug.exe
  Starting test_once ...
Either it does not terminates (still running after half an hour, eating
100% CPU time on one of the two CPUs), or it crashes rather quickly:
  $ ./bug.exe
  Starting test_once ...Segmentation fault (core dumped)

This is on a machine with 2 virtual processors:

$ cat /proc/cpuinfo 
processor       : 0
vendor_id       : GenuineIntel
type            : primary processor
cpu family      : 6
model           : 12
model name      : Intel(R) Atom(TM) CPU N270   @ 1.60GHz
stepping        : 2
brand id        : 0
cpu count       : 2
apic id         : 0
cpu MHz         : 1600
fpu             : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat clfl dtes acpi mmx fxsr sse sse2 ss htt tmi pbe pni monitor ds_cpl tm2 est
processor       : 1
vendor_id       : GenuineIntel
type            : primary processor
cpu family      : 6
model           : 12
model name      : Intel(R) Atom(TM) CPU N270   @ 1.60GHz
stepping        : 2
brand id        : 0
cpu count       : 2
apic id         : 1
cpu MHz         : 1599
fpu             : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat clfl dtes acpi mmx fxsr sse sse2 ss htt tmi pbe pni monitor ds_cpl tm2 est

You can see what the program is doing before it crahes or while it loops,
by setting   #define ENABLE_DEBUGGING 1  in line 25.

I have other test programs which exercise pthread_mutex_*, pthread_rwlock_*,
and pthread_join. These work fine. My suspicion therefore lies on pthread_once.

Bruno


-------------- next part --------------
A non-text attachment was scrubbed...
Name: bug.c
Type: text/x-csrc
Size: 5805 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20090810/e1fff7fe/attachment.bin>
-------------- next part --------------
--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


More information about the Cygwin mailing list