delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/05/05/16:05:50

From: <ams AT ludd DOT luth DOT se>
Message-Id: <200305051948.h45Jm1LI012342@speedy.ludd.luth.se>
Subject: Re: Yet another try on nan in strto{f,d,ld}
In-Reply-To: <3405-Wed30Apr2003205339+0300-eliz@elta.co.il> "from Eli Zaretskii
at Apr 30, 2003 08:53:39 pm"
To: djgpp-workers AT delorie DOT com
Date: Mon, 5 May 2003 21:48:01 +0200 (CEST)
X-Mailer: ELM [version 2.4ME+ PL78 (25)]
MIME-Version: 1.0
X-MailScanner: Found to be clean
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

According to Eli Zaretskii:
> > From: <ams AT ludd DOT luth DOT se>
> > Date: Wed, 30 Apr 2003 13:00:27 +0200 (CEST)
> > 
> > From what I can see the problem is in printf(), not in any assignments
> > strtof() does.
> 
> Then the crashes are not relevant to `strtof'.

Ok. t-strtof.c with FPU exceptions on (is that the right terminology?)
and compiled with printf.c, doprnt.c and -g stabs+ in plain DOZE on a
Pentium says (Yes, printf.c. I didn't look close enough on the crash
message before recompiling, but that shouldn't matter.):

A:\>ts3
FPU CW: 0x00000340.
float tests:
Exiting due to signal SIGFPE
Floating Point exception at eip=00005e21, x87 status=b1a0
eax=000917ac ebx=00092c2b ecx=0000000c edx=00090f40 esi=000918ad edi=00000006
ebp=0009171c esp=00091718 program=A:\TS3.EXE
cs: sel=00bf  base=00116000  limit=0009ffff
ds: sel=00c7  base=00116000  limit=0009ffff
es: sel=00c7  base=00116000  limit=0009ffff
fs: sel=009f  base=000051d0  limit=0000ffff
gs: sel=00d7  base=00000000  limit=0010ffff
ss: sel=00c7  base=00116000  limit=0009ffff
App stack: [00092dc4..00012dc4]  Exceptn stack: [00012d44..00010e04]
 
Call frame traceback EIPs:
  0x00005e21 __modfl+33, file a:/doprnt.c, line 924
  0x0000338d cvtl+417, file a:/doprnt.c, line 592
  0x000028d2 _doprnt+1774, file a:/doprnt.c, line 296
  0x0000583e sprintf+46, file a:/doprnt.c, line 924
  0x00001d49 main+189, file a:/tstrtof2.c, line 141
  0x0000577c __crt1_startup+204, file a:/doprnt.c, line 924
 
A:\>symify -o ts3.sym ts3.exe

doprnt.c, lines 574-595 are:

  number = integer;
  fract = modfl(number, &integer);
  /* If integer is zero then we need to look at where the sig figs are */
  if (integer<1) {
        /* If fract is zero the zero before the decimal point is a sig fig */
        if (fract==0.0) doingzero=1;
        /* If fract is non-zero all sig figs are in fractional part */
        else doextradps=1;
  }
  /*
   * get integer portion of number; put into the end of the buffer; the
   * .01 is added for modf(356.0 / 10, &integer) returning .59999999...
   * The test p >= startp is due to paranoia: buffer length is guaranteed
   * to be large enough, but if tmp is somehow a NaN, this loop could
   * eventually blow away the stack.
   */
  for (; integer && p >= startp; ++expcnt)
  {
    tmp = modfl(integer * 0.1L , &integer);
    *p-- = tochar((int)((tmp + .01L) * 10));
  }
  switch(fmtch)

Line 592 is "tmp = modfl(integer * 0.1L , &integer);".

Worth to note is that the previous modfl() at line 575 worked fine.

And this is an "objdump -d" of the relevant instructions in modfl:

00005e00 <___modfl>:
    5e00:       55                      push   %ebp
    5e01:       89 e5                   mov    %esp,%ebp
    5e03:       83 ec 04                sub    $0x4,%esp
    5e06:       db 6d 08                fldt   0x8(%ebp)
    5e09:       8b 45 14                mov    0x14(%ebp),%eax
    5e0c:       d9 7d fe                fnstcw 0xfffffffe(%ebp)
    5e0f:       66 8b 55 fe             mov    0xfffffffe(%ebp),%dx
    5e13:       80 ce 0c                or     $0xc,%dh
    5e16:       66 89 55 fc             mov    %dx,0xfffffffc(%ebp)
    5e1a:       d9 6d fc                fldcw  0xfffffffc(%ebp)
    5e1d:       d9 c0                   fld    %st(0)
    5e1f:       d9 fc                   frndint 
    5e21:       d9 6d fe                fldcw  0xfffffffe(%ebp)
    5e24:       d9 c0                   fld    %st(0)
    5e26:       db 38                   fstpt  (%eax)
    5e28:       de e9                   fsubrp %st,%st(1)
    5e2a:       c9                      leave  
    5e2b:       c3                      ret    

Soooo....? (I haven't a clue.)


What does "x87 status=b1a0" in the crash message tell us?


Right,

						MartinS

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019