Buglet in reader/shell??

Bjorn Gustavsson bjorn@REDACTED
Tue Mar 19 09:38:29 CET 2002


It is actually not the Erlang emulator that is hanging, but the shell process
that has died. By pressing Ctrl+G, you can start up a new shell.

Investigating further, the problem seems to be in the list_to_float/1 BIF.
list_to_float/1 calls atof(), which in this case returns the special value "inf".
This can be seen if you immediately pass the return value to erlang:display/1
(which basically just calls printf()):

3> erlang:display(list_to_float("1.0e400")).
inf
true
4> 

What apparently happened, is that the "inf" value caused a floating point
exception in a later operation in the shell process, when the shell process
did not expect any problem and didn't protect the operation by a catch.

The cure to the problem is probably to use strtod() instead of atof().
strtod() has better error reporting.

/Bjorn

Kostis Sagonas <kostis@REDACTED> writes:

> On the SPARC, I get:
> 
> ------------------------------------------------------------
> Erlang (BEAM) emulator version 2002.03.10 [source] [hipe]
> 
> Eshell V2002.03.10  (abort with ^G)
> 1> 3.14e+400.
> ** 1: illegal float **
> ------------------------------------------------------------
> 
> as it should be.  On an x86 running Linux, reading the same
> float appears to result in some sort of an infinite loop.
> 
> Kostis.
> 
> PS. I am only running HiPE-enabled systems these days, but I do 
>     not see where this might influence the behaviour of the reader
>     or the Erlang shell.
> 

-- 
Björn Gustavsson            Ericsson Utvecklings AB
bjorn@REDACTED      ÄT2/UAB/F/P
			    BOX 1505
+46 8 727 56 87 	    125 25 Älvsjö



More information about the erlang-questions mailing list