Re: Signal support under Cygwin
On Thu, May 06, 2010 at 12:53:33AM +0100, Dave Korn wrote: On 05/05/2010 23:57, Nicholas Sherlock wrote: On 6/05/2010 2:23 a.m., Christopher Faylor wrote: On Thu, May 06, 2010 at 02:20:54AM +1200, Nicholas Sherlock wrote: On 28/04/2010 4:25 p.m., Nicholas Sherlock wrote: Is this supposed to work? Nobody knows if Cygwin signals work? Could anybody reproduce the crash from my example code at least on their machines? Investigating this is on my todo list. cgf Okay, thanks :) I have confirmed that the bug exists on w2ksp4, so it's not a Win7, 64-bit or UAC or DEP thing; looks like a real bug in the Cygwin DLL. Corinna and I have been discussing this in private email so I know this is a real problem. I just don't have a concentrated block of time to track it down yet. cgf -- 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
Re: Signal support under Cygwin
On 28/04/2010 4:25 p.m., Nicholas Sherlock wrote: Is this supposed to work? Nobody knows if Cygwin signals work? Could anybody reproduce the crash from my example code at least on their machines? Cheers, Nicholas Sherlock -- 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
Re: Signal support under Cygwin
On Thu, May 06, 2010 at 02:20:54AM +1200, Nicholas Sherlock wrote: On 28/04/2010 4:25 p.m., Nicholas Sherlock wrote: Is this supposed to work? Nobody knows if Cygwin signals work? Could anybody reproduce the crash from my example code at least on their machines? Investigating this is on my todo list. cgf -- 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
Re: Signal support under Cygwin
On 6/05/2010 2:23 a.m., Christopher Faylor wrote: On Thu, May 06, 2010 at 02:20:54AM +1200, Nicholas Sherlock wrote: On 28/04/2010 4:25 p.m., Nicholas Sherlock wrote: Is this supposed to work? Nobody knows if Cygwin signals work? Could anybody reproduce the crash from my example code at least on their machines? Investigating this is on my todo list. cgf Okay, thanks :) Cheers, Nicholas Sherlock -- 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
Re: Signal support under Cygwin
On 05/05/2010 23:57, Nicholas Sherlock wrote: On 6/05/2010 2:23 a.m., Christopher Faylor wrote: On Thu, May 06, 2010 at 02:20:54AM +1200, Nicholas Sherlock wrote: On 28/04/2010 4:25 p.m., Nicholas Sherlock wrote: Is this supposed to work? Nobody knows if Cygwin signals work? Could anybody reproduce the crash from my example code at least on their machines? Investigating this is on my todo list. cgf Okay, thanks :) I have confirmed that the bug exists on w2ksp4, so it's not a Win7, 64-bit or UAC or DEP thing; looks like a real bug in the Cygwin DLL. cheers, DaveK -- 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
Signal support under Cygwin
Hi everybody, I've got some code on Linux which attempts to take periodic samples of my multi- threaded program to find out what task each thread is working on. For this I am installing a signal handler for each thread, and periodically sending SIGUSR1 to each thread I want to check with pthread_kill. This works flawlessly on Linux, but crashes after a short interval on Cygwin on Windows 7 64-bit. My code is: #include stdlib.h #include stdio.h #include assert.h #include signal.h #include unistd.h #include pthread.h volatile sig_atomic_t pauses = 0; static void profiling_sample(int signum) { (void) signum; sig_atomic_t old_value = pauses; ++old_value; /* Might lose concurrent updates to 'pauses' here. Not a big deal. */ pauses = old_value; } static void * childthread(void * arg) { (void) arg; for (;;) { sleep(1000); } } #define NUM_THREADS 8 int main(void) { int i; pthread_t handles[NUM_THREADS]; struct sigaction action; action.sa_handler = profiling_sample; action.sa_flags = 0; sigemptyset(action.sa_mask); assert(sigaction(SIGUSR1, action, NULL) == 0); for (i = 0; i NUM_THREADS; i++) { assert(pthread_create(handles[i], NULL, childthread, NULL) == 0); } printf(Delivered signals is at least:\n); for (;;) { for (i = 0; i NUM_THREADS; i++) { int err = pthread_kill(handles[i], SIGUSR1); if (err) { fprintf(stderr, Error from pthread_kill (%d)\n, err); exit(-1); } } printf(%d\n, pauses); } return EXIT_SUCCESS; } My Cygwin is: $ uname -a CYGWIN_NT-6.1-WOW64 NickLaptop 1.7.5(0.225/5/3) 2010-04-12 19:07 i686 Cygwin I am building with: gcc -std=gnu99 -g3 -W -Wall -o sigtest.exe sigtest.c -lpthread A typical run on Cygwin shows the pauses value counting upwards to about 4000 before the program either hangs without printing anything or causes a segfault (without a useful looking stacktrace): (gdb) thread apply all where Thread 10 (thread .0x179c): #0 0x1b4bdb2c in ?? () #1 0x03e8 in ?? () #2 0x1b4bce64 in ?? () #3 0x1b4bcd98 in ?? () #4 0x610df995 in pthread::thread_init_wrapper () from /usr/bin/cygwin1.dll Backtrace stopped: frame did not save the PC Thread 9 (thread .0x14fc): #0 0x77bef871 in ntdll!RtlUpdateClonedSRWLock () from /cygdrive/c/Windows/system32/ntdll.dll #1 0x77bef871 in ntdll!RtlUpdateClonedSRWLock () from /cygdrive/c/Windows/system32/ntdll.dll #2 0x77490816 in WaitForSingleObjectEx () from /cygdrive/c/Windows/syswow64/KernelBase.dll #3 0x01e4 in ?? () #4 0x in ?? () Thread 8 (thread .0x15a4): #0 0x77bef8dd in ntdll!RtlUpdateClonedSRWLock () from /cygdrive/c/Windows/system32/ntdll.dll #1 0x77bef8dd in ntdll!RtlUpdateClonedSRWLock () from /cygdrive/c/Windows/system32/ntdll.dll #2 0x7748d232 in WriteFile () from /cygdrive/c/Windows/syswow64/KernelBase.dll #3 0x0124 in ?? () #4 0x in ?? () Thread 7 (thread .0x1610): #0 0x77bef871 in ntdll!RtlUpdateClonedSRWLock () from /cygdrive/c/Windows/system32/ntdll.dll #1 0x77bef871 in ntdll!RtlUpdateClonedSRWLock () from /cygdrive/c/Windows/system32/ntdll.dll #2 0x77490816 in WaitForSingleObjectEx () from /cygdrive/c/Windows/syswow64/KernelBase.dll #3 0x00f0 in ?? () #4 0x in ?? () Thread 6 (thread .0x144c): #0 0x77bef871 in ntdll!RtlUpdateClonedSRWLock () from /cygdrive/c/Windows/system32/ntdll.dll #1 0x77bef871 in ntdll!RtlUpdateClonedSRWLock () from /cygdrive/c/Windows/system32/ntdll.dll #2 0x77490816 in WaitForSingleObjectEx () from /cygdrive/c/Windows/syswow64/KernelBase.dll #3 0x00f0 in ?? () #4 0x in ?? () Thread 5 (thread .0x125c): #0 0x77bef871 in ntdll!RtlUpdateClonedSRWLock () from /cygdrive/c/Windows/system32/ntdll.dll #1 0x77bef871 in ntdll!RtlUpdateClonedSRWLock () from /cygdrive/c/Windows/system32/ntdll.dll #2 0x77490816 in WaitForSingleObjectEx () from /cygdrive/c/Windows/syswow64/KernelBase.dll #3 0x00f0 in ?? () #4 0x in ?? () Thread 4 (thread .0x414): #0 0x77bef871 in ntdll!RtlUpdateClonedSRWLock () from /cygdrive/c/Windows/system32/ntdll.dll #1 0x77bef871 in ntdll!RtlUpdateClonedSRWLock () from /cygdrive/c/Windows/system32/ntdll.dll #2 0x77490816 in WaitForSingleObjectEx () from /cygdrive/c/Windows/syswow64/KernelBase.dll #3 0x00f0 in ?? () #4 0x in ?? () Thread 3 (thread .0x804): #0 0x77bef871 in ntdll!RtlUpdateClonedSRWLock () from /cygdrive/c/Windows/system32/ntdll.dll #1 0x77bef871 in ntdll!RtlUpdateClonedSRWLock () from /cygdrive/c/Windows/system32/ntdll.dll #2 0x77490816 in WaitForSingleObjectEx () from