Mail Archives: djgpp/1998/05/03/17:36:38
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 <stdlib.h>
#include <stdio.h>
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 <stdlib.h>?
* 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
<float.h>) 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
- Raw text -