This is the mail archive of the cygwin-developers mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: SIGFPE in CVS HEAD


[Moved to cygwin-developers]

On Mar 29 23:05, Yaakov (Cygwin/X) wrote:
> Corinna,
> 
> One of your changes post-1.7.9 is causing a SIGFPE in the DLL:
> 
> $ cat test.c
> #include <unistd.h>
> int main(void) { sleep(1); return 0; }
> 
> $ gcc -o test test.c
> 
> $ ./test
> Floating point exception

Works fine for me on XP and W7.

> $ gdb ./test
> GNU gdb (GDB) 7.2
> [snip]
> (gdb) run
> Starting program: /usr/src/src/winsup/cygwin/test
> [New Thread 5684.0xefc]
> warning: section .gnu_debuglink not found in
> /cygdrive/c/cygwin17/bin/cygwin1.dbg
> [New Thread 5684.0xff4]
> 
> Program received signal SIGFPE, Arithmetic exception.
> 0x610cd147 in nanosleep (rqtp=0x28cc58, rmtp=0x28cc50)
>     at ../../../../winsup/cygwin/signal.cc:114
> 114                       + resolution - 1) / resolution) * resolution;

The only possible cause for this line throwing an exception is if
resolution is 0.  That should be impossible, unless the
NtQueryTimerResolution function returns a resolution < 10000.  Since the
function returns values in 100ns intervals, this would result in a
resolution < 1 ms.  Since the resolution of the hires_ms class is in
milliseconds, it would be 0.

[time passes]

Please apply this patch for testing:

Index: times.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/times.cc,v
retrieving revision 1.104
diff -u -p -r1.104 times.cc
--- times.cc	29 Mar 2011 10:21:30 -0000	1.104
+++ times.cc	30 Mar 2011 08:54:02 -0000
@@ -804,7 +804,11 @@ hires_ms::resolution ()
 
       status = NtQueryTimerResolution (&coarsest, &finest, &actual);
       if (NT_SUCCESS (status))
-	minperiod = (DWORD) actual / 10000L;
+	{
+	  system_printf ("coarsest: %lu, finest: %lu, actual: %lu\n",
+			 coarsest, finest, actual);
+	  minperiod = (DWORD) actual / 10000L;
+	}
       else
 	{
 	  /* Try to empirically determine current timer resolution */

Here's what NtQueryTimerResolution returns on my systems:

XP 32 bit: coarsest: 156250, finest: 10000, actual: 156250
W7 32 bit: coarsest: 156001, finest: 5000, actual: 156000

XP 64 bit: coarsest: 156250, finest: 10000, actual: 156250
W7 64 bit: coarsest: 156001, finest: 5000, actual: 10000

On your system the 'actual' value is apparently < 10000 for some reason.

Anyway, I'll make sure that resolution is never < 1.


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]