home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / bsd / 5623 < prev    next >
Encoding:
Text File  |  1992-09-12  |  3.8 KB  |  79 lines

  1. Newsgroups: comp.unix.bsd
  2. Path: sparky!uunet!spool.mu.edu!agate!dog.ee.lbl.gov!hellgate.utah.edu!fcom.cc.utah.edu!cs.weber.edu!terry
  3. From: terry@cs.weber.edu (A Wizard of Earth C)
  4. Subject: Re: Program dies with FP Exception
  5. Message-ID: <1992Sep13.083846.6134@fcom.cc.utah.edu>
  6. Sender: news@fcom.cc.utah.edu
  7. Organization: Weber State University  (Ogden, UT)
  8. References: <STARK.92Sep13002650@sbstark.cs.sunysb.edu>
  9. Date: Sun, 13 Sep 92 08:38:46 GMT
  10. Lines: 67
  11.  
  12. In article <STARK.92Sep13002650@sbstark.cs.sunysb.edu> stark@cs.sunysb.edu (Gene Stark) writes:
  13. >Here's a tough one I've been trying to track down -- maybe somebody out there
  14. >who knows more can guess what is going on.
  15. >
  16. >I am running 386BSD on a 486/33 system with 4MB RAM and a 210MB Connor IDE
  17. >drive.  A program I was working on dies on Signal 8 (Floating point exception)
  18. >in a perfectly repeatable fashion.  It is not so easy to tell where the
  19. >exception actually comes from, though, because the signal seems to be getting
  20. >delivered to the process much later, when it is leaving the system after
  21. >a call to "write".  I haven't been able to get a small test program that
  22. >repeats the bug, however there seem to be several crucial elements involved:
  23. >
  24. >    (1)  A call to "atof", which returns a double that is then
  25. >        stored in a temporary on the stack.  Removing the call
  26. >        removes the error.
  27. >
  28. >    (2)  The actual magnitude of the number being converted by "atof".
  29. >        I found that the string "1e10" and "1e12" cause the error,
  30. >        but "1e9", "1e6", and "0.0" do not.
  31. >
  32. >    (3)  Some later "write" system calls.  The signal is actually
  33. >        delivered on the fourth call to write after the atof.
  34. >        What is happening in the interim is just C code without
  35. >        any other system calls.  I do not know what causes the
  36. >        signal to get delivered when it actually does.
  37.  
  38. First of all, like all other signals, the SIGFPE gets delivered to a process
  39. as a result of the sigtrampoline code.  The *only* way you get a signal is
  40. on return from a system call.  The problem is that there appears to be no
  41. code in the library which forces a check for the exception *immediately*
  42. after the floating point function call.  This is aggravated by the fact
  43. that GCC likes to in-line 386 floating point (from what little experimentation
  44. I've done).  This has the effect of defeating any fixes made at the library
  45. level to hit the sigtrampoline code to check for an exception.
  46.  
  47. Second, are you using a real FPU, or are you using the emulation?  I know
  48. that I *could* try it myself, but I prefer to arrive at an expected answer
  49. before experimenting (I guess my physics background shows).
  50.  
  51. Third, you were aware that for a 16 bit value to be multiplied/divided, you
  52. have to have a 32 bit area to receive the value, and for a 32 bit, you have
  53. to have a 64 bit receiver?  Perhaps you are truly getting an exception.
  54.  
  55. Fourth, I believe that the math stuff is actually not being done at the
  56. highest floating point resoloution (I read this in the newgroup here, so
  57. I could be totally wrong 8-)).  This would lend credence to the idea that
  58. you are actually getting an exception.
  59.  
  60. Fifth, there is a well known problem that causes 'ps' to die with the same
  61. exception -- the problem occurs when you have a double lvalue and assign it
  62. to an undeclared (int) rvalued function.  Are you sure that atof() is declared
  63. extern double somewhere?
  64.  
  65. Hope this helps narrow the problem.
  66.  
  67.  
  68.                     Terry Lambert
  69.                     terry_lambert@gateway.novell.com
  70.                     terry@icarus.weber.edu
  71. ---
  72. Any opinions in this posting are my own and not those of my present
  73. or previous employers.
  74. -- 
  75. -------------------------------------------------------------------------------
  76.                                         "I have an 8 user poetic license" - me
  77.  Get the 386bsd FAQ from agate.berkeley.edu:/pub/386BSD/386bsd-0.1/unofficial
  78. -------------------------------------------------------------------------------
  79.