Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" To: Shaun Jackman , djgpp AT delorie DOT com From: Nate Eldredge Subject: Re: strtod() crashes on the call strtod("$.", &endp); Date: Sun, 3 May 1998 09:57:03 -0700 Message-ID: <19980503165659.AAA13333@ppp122.cartsys.com> Precedence: bulk At 02:42 5/3/1998 -0700, Shaun Jackman wrote: >I have a program that is crashing within strtod(). I found it unusual >that it would crash during a library function call. Maybe you somebody >out there can shed some light on this. > >I'm writing a Forth compiler, and was testing it on this script: >1 if > '1 == 1' $. > 'Cool' $. >then > >0 if > 'Uh oh' $. >then > > >Unfortunately, it crashes. >I ran gdb on it, and after the crash got a stack frame back-trace. >The result was: > >Program received signal SIGFPE, Arithmetic exception. >0x25df7 in strtod () >(gdb) bt >#0 0x25df7 in strtod () >#1 0x18f9 in is_literal (lexema=0x7f111 "$.") at forth.c:62 >#2 0x2285 in forth ( > tp=0x7f114 " 'Cool' $. then 0 if 'Uh oh' $. then ") > at forth.c:433 >#3 0x1738 in main () >#4 0x253e6 in __crt1_startup () >(gdb) > >Which means it crashed on the call strtod("$.", &endp); >I have no idea why. > >I am using gcc version 2.7.2.1 I can't reproduce this. This program: #include #include int main(void) { char *endp; printf("%f\n", strtod("$.", &endp)); return 0; } just prints out "0.00000" and doesn't crash. Here are some thoughts: * Are you sure you #include ? * Are you using DJGPP libc 2.01? * Does the crash happen consistently? * Can *you* reproduce the problem with a simple call to `strtod("$.",...)'? * Is it possible that the calling function is getting garbage in the FPU registers somehow? I doubt it, but try calling `_fpreset()' (#include ) right before the call to `strtod' and see if anything changes. * Have you changed the exception state with `_control87', perhaps to cause an exception under some previously benign condition? Hmm. Hope this gets figured out. Nate Eldredge nate AT cartsys DOT com