Bug ... in Erlang

classic Classic list List threaded Threaded
19 messages Options
Reply | Threaded
Open this post in threaded view
|

Bug ... in Erlang

Joe Williams-2


 Try typing the following:

        > 1.0e309.

 Is this a bug?

 /Joe



Reply | Threaded
Open this post in threaded view
|

Bug ... in Erlang

Kent Boortz-2

Joe Armstrong <joe> writes:
>  Try typing the following:
>
> > 1.0e309.
>
>  Is this a bug?

You mean

  Eshell V5.2.3.6  (abort with ^G)
  1> 1.0e309.
  ** 1: illegal float **
  1>

Don't think it is a bug. On Solaris and Linux max double is defined as

  /usr/include/values.h:#define   MAXDOUBLE       1.79769313486231570e+308
  /usr/include/values.h:#define   MINDOUBLE       4.94065645841246544e-324

kent


Reply | Threaded
Open this post in threaded view
|

Bug ... in Erlang

Miguel Barreiro Paz-2


> You mean
>
>   Eshell V5.2.3.6  (abort with ^G)
>   1> 1.0e309.
>   ** 1: illegal float **

Solaris 8 on SPARC, OTP compiled 'by hand':
Eshell V5.1.1  (abort with ^G)
1> 1.0e309.
** 1: illegal float **

Debian GNU/Linux on x86 "sid"  (testing/unstable), OTP installed from the
Debian package:

Eshell V5.2.3.3  (abort with ^G)
1>  1.0e309.
(hangs forever, eating a bit of CPU, memory not growing)



Reply | Threaded
Open this post in threaded view
|

Bug ... in Erlang

Björn Gustavsson-3
In reply to this post by Kent Boortz-2
Windows 2000 Professional:

Eshell V5.2  (abort with ^G)
1> 1.0e309.
1.00000e+0

Kent Boortz wrote:

>You mean
>
>  Eshell V5.2.3.6  (abort with ^G)
>  1> 1.0e309.
>  ** 1: illegal float **
>  1>
>  
>



Reply | Threaded
Open this post in threaded view
|

Bug ... in Erlang

Serge Aleynikov-4
In reply to this post by Joe Williams-2
I am not sure about Erlang, but in C (32bit) the highest value in the
range of the double precision floating point type is 1.700000E+308

I suppose the proper behavior would be to get an illegal floating point
exception thrown.

19> 1.799E+308.
1.00000e+0
20> 1.79E+308.
1.79000e+308

Serge

Joe Armstrong wrote:

>
>  Try typing the following:
>
> > 1.0e309.
>
>  Is this a bug?
>
>  /Joe
>
>




Reply | Threaded
Open this post in threaded view
|

Bug ... in Erlang

Joe Williams-2
In reply to this post by Kent Boortz-2

> Joe Armstrong <joe> writes:
> >  Try typing the following:
> >
> > > 1.0e309.
> >
> >  Is this a bug?
>
> You mean
>
>   Eshell V5.2.3.6  (abort with ^G)
>   1> 1.0e309.
>   ** 1: illegal float **
>   1>

This does not happen on my machine - the program just never returns
It doesn't seem to use CPU time it just *hangs* (seem's like I'm not the only
one too) - I verified that I'm using R9B-1 (latest and best TM)

>
> Don't think it is a bug. On Solaris and Linux max double is defined as
>
>   /usr/include/values.h:#define   MAXDOUBLE       1.79769313486231570e+308
>   /usr/include/values.h:#define   MINDOUBLE       4.94065645841246544e-324
>

This I don't understand.  My /usr/include/values.h doesn't
define MAXDOUBLE I found this (eventually)

#define GSL_DBL_MIN        2.2250738585072014e-308
#define GSL_DBL_MAX        1.7976931348623157e+308

in /usr/include/gsl/gsl_machine.h

This is what I also found in a document describig the format of
IEEE 754 reals. (I'm assuming that Erlang floats are actually IEEE 754
64 bit reals) is this so???

/Joe


> kent
>



Reply | Threaded
Open this post in threaded view
|

Bug ... in Erlang

Tony Rogvall-3
In reply to this post by Kent Boortz-2
On Tue, 2003-06-17 at 14:20, Kent Boortz wrote:

> Joe Armstrong <joe> writes:
> >  Try typing the following:
> >
> > > 1.0e309.
> >
> >  Is this a bug?
>
> You mean
>
>   Eshell V5.2.3.6  (abort with ^G)
>   1> 1.0e309.
>   ** 1: illegal float **
>   1>
>
No I guess joe meant (R9B-1 on linux)

Eshell V5.2.3.3  (abort with ^G)
1> 1.0e309.



(Nothing :-()

I looks like the shell dies without a catch!


--
Tony Rogvall <tony>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 307 bytes
Desc: This is a digitally signed message part
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20030617/cdea020c/attachment.bin>

Reply | Threaded
Open this post in threaded view
|

Bug ... in Erlang

Daniel Néri-2
In reply to this post by Miguel Barreiro Paz-2
Miguel Barreiro Paz <enano> writes:

> Solaris 8 on SPARC, OTP compiled 'by hand':
> Eshell V5.1.1  (abort with ^G)
> 1> 1.0e309.
> ** 1: illegal float **
>
> Debian GNU/Linux on x86 "sid"  (testing/unstable), OTP installed from the
> Debian package:
>
> Eshell V5.2.3.3  (abort with ^G)
> 1>  1.0e309.
> (hangs forever, eating a bit of CPU, memory not growing)

I think we've had this discussion before:

  http://www.erlang.org/ml-archive/erlang-questions/200203/msg00049.html


Regards,
 --Daniel



Reply | Threaded
Open this post in threaded view
|

Bug ... in Erlang

Fredrik Linder-2
In reply to this post by Serge Aleynikov-4
Would not the *proper* behaviour be to implement a big-float mechanism, in
the same spirit as for integers?

/Fredrik

> -----Original Message-----
> From: owner-erlang-questions
> [mailto:owner-erlang-questions]On Behalf Of Serge Aleynikov
> Sent: den 17 juni 2003 15:16
> To: Joe Armstrong
> Cc: erlang-questions
> Subject: Re: Bug ... in Erlang
>
>
> I am not sure about Erlang, but in C (32bit) the highest value in the
> range of the double precision floating point type is 1.700000E+308
>
> I suppose the proper behavior would be to get an illegal floating point
> exception thrown.
>
> 19> 1.799E+308.
> 1.00000e+0
> 20> 1.79E+308.
> 1.79000e+308
>
> Serge
>
> Joe Armstrong wrote:
> >
> >  Try typing the following:
> >
> > > 1.0e309.
> >
> >  Is this a bug?
> >
> >  /Joe
> >
> >
>
>
>



Reply | Threaded
Open this post in threaded view
|

Bug ... in Erlang

Peter H|gfeldt
How many decimals would you have for the value 1/3?

Unlimited precision perhaps?

Peter

> Would not the *proper* behaviour be to implement a big-float mechanism,
> in the same spirit as for integers?
>
> /Fredrik





Reply | Threaded
Open this post in threaded view
|

Bug ... in Erlang

Thomas Lindgren-5
In reply to this post by Fredrik Linder-2

--- Fredrik Linder <fredrik.linder>
wrote:
> Would not the *proper* behaviour be to implement a
> big-float mechanism, in
> the same spirit as for integers?

If we want to do it *properly*, my suggestion is to
take a page from what Common Lisp did.

E.g.,
<http://www-2.cs.cmu.edu/Groups/AI/html/hyperspec/HyperSpec/Body/sec_12-1.html>

Best,
Thomas


__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com


Reply | Threaded
Open this post in threaded view
|

Bug ... in Erlang

Raimo Niskanen-7
In reply to this post by Joe Williams-2
Try also:

1> 1.b.

On our R9B, patched, erl_eval starts a death spin. There is probably
some error checking in the shell (evaluator) that is missing.

Our soon to come R9C does not show the same error; the shell and
erl_eval has been somewhat rewritten. Nor does "1.0e309." death spin.

17> 1.0e309.
** 1: illegal float **
17> .
** 1: syntax error before: '.' **

Unfortunately there is a semantic difference with the new erl_scan
(compared to the old), that it does not read input until the full stop
if there is a scan error before that. Therefore the syntax error on the
'.'. It can probably be fixed, but the question is if I must?

The same applies for:

17> 16#.
** 1: illegal integer **
17> .
** 1: syntax error before: '.' **

/ Raimo Niskanen, Erlang/OTP, Ericsson AB.



Joe Armstrong wrote:
>
>  Try typing the following:
>
> > 1.0e309.
>
>  Is this a bug?
>
>  /Joe
>



Reply | Threaded
Open this post in threaded view
|

Bug ... in Erlang

Raimo Niskanen-7
In reply to this post by Björn Gustavsson-3
Can everybody try:



17> erlang:list_to_float("1.0e309").

=ERROR REPORT==== 17-Jun-2003::18:54:46 ===
Error in process <0.46.0> with exit value:
{badarg,[{erlang,list_to_float,["1.0e309"]},{erl_eval,do_apply,5},{shell,eval_loop,2}]}

** exited: {badarg,[{erlang,list_to_float,["1.0e309"]},
                     {erl_eval,do_apply,5},
                     {shell,eval_loop,2}]} **



on all your fancy platforms and see what you get. We might have at least
two competing problems here.

/ Raimo Niskanen, Erlang/OTP, Ericsson AB.



Bj?rn Bylander wrote:

> Windows 2000 Professional:
>
> Eshell V5.2  (abort with ^G)
> 1> 1.0e309.
> 1.00000e+0
>
> Kent Boortz wrote:
>
>> You mean
>>
>>  Eshell V5.2.3.6  (abort with ^G)
>>  1> 1.0e309.
>>  ** 1: illegal float **
>>  1>  
>>
>



Reply | Threaded
Open this post in threaded view
|

Suspected Spam: Re: Bug ... in Erlang

Serge Aleynikov-4
In reply to this post by Raimo Niskanen-7
Running Win2000 Sp3:

(node1)1> os:type().
{win32,nt}
(node1)2> erlang:list_to_float("1.0e309").
1.00000e+0
(node1)3> 1.b.

hangs forever.

Raimo Niskanen wrote:

> Try also:
>
> 1> 1.b.
>
> On our R9B, patched, erl_eval starts a death spin. There is probably
> some error checking in the shell (evaluator) that is missing.
>
> Our soon to come R9C does not show the same error; the shell and
> erl_eval has been somewhat rewritten. Nor does "1.0e309." death spin.
>
> 17> 1.0e309.
> ** 1: illegal float **
> 17> .
> ** 1: syntax error before: '.' **
>
> Unfortunately there is a semantic difference with the new erl_scan
> (compared to the old), that it does not read input until the full stop
> if there is a scan error before that. Therefore the syntax error on the
> '.'. It can probably be fixed, but the question is if I must?
>
> The same applies for:
>
> 17> 16#.
> ** 1: illegal integer **
> 17> .
> ** 1: syntax error before: '.' **
>
> / Raimo Niskanen, Erlang/OTP, Ericsson AB.
>
>
>
> Joe Armstrong wrote:
>
>>
>>  Try typing the following:
>>
>>     > 1.0e309.
>>
>>  Is this a bug?
>>
>>  /Joe
>>
>
>


--
================================================================
| Serge Aleynikov                          Tel: (973) 438-3436
| MIS Telecom                              Fax: (973) 438-1457
| IDT Corp.                                   serge
================================================================



Reply | Threaded
Open this post in threaded view
|

Bug ... in Erlang

chris.danx
In reply to this post by Raimo Niskanen-7
Raimo Niskanen wrote:
> Can everybody try:
>

 > 1.b.

hangs

>
> 17> erlang:list_to_float("1.0e309").

hangs.


Running R9B-1 on Linux i686



Reply | Threaded
Open this post in threaded view
|

Bug ... in Erlang

Joachim Durchholz
In reply to this post by Raimo Niskanen-7
Raimo Niskanen wrote:
> Can everybody try:
>
> 17> erlang:list_to_float("1.0e309").

Here's my transcript:

---
Erlang (BEAM) emulator version 5.2.3.3 [threads:0]

Eshell V5.2.3.3  (abort with ^G)
1> erlang:list_to_float("1.0e309").
1.00000e+0
2>
---

Weirder and weirder...
This is running on Win 2K.

Regards,
Jo



Reply | Threaded
Open this post in threaded view
|

Bug ... in Erlang

Raimo Niskanen-7
In reply to this post by Joe Williams-2
These bug will be fixed in R9C:



There was bug with list_to_float/1 returning weird floats on some
Linuxes and on (all) Windowses.

1> erlang:display(list_to_float("1.0e309")). % Linux
inf
true

1> erlang:display(list_to_float("1.0e309")). % Windows
1.#INF000e+000
true
2> list_to_float("1.0e309").
1.00000e+0

Here "inf" and "1.#INF000e+000" are infinity floats (that should not
exist in Erlang). You can try to assign them to a variable and
performing tests on them. For example list_to_float("1.0e309") > 1.0e308
-> true. But printing with io:format/2 (as the shell does) crashes on
Linux and prints 1.00000e+0 on Windows.

So, list_to_float/1 has been rewritten to use strtod() (previously
atof() on Unixish systems and sscanf("%lf",..) on Windows) and check
errors on all platforms. Hopefully no more malicious floats.



There was a problem when the shell crashed, which it seldom does. It did
when printing infinity floats on Linux. You could type ^G to get to the
job handler menu and there start a new shell, but not many knew that.

So, the shell handling has been rewritten to automatically start a new
shell if it crashes.



For snapshot builders and for us internally there was a problem with the
new erl_scan:

1> 1.0e309.
** 1: illegal float **
2> .
** 1: syntax error before: '.' **

The new scanner left unscanned data on the input stream after a scan
error. Therefore the second '.' command.

So, the new erl_scan has been rewritten to always scan to full stop
('.') while recording errors, and finally check if there were any.

Note that you can still do (as before):

1> a. b.
a
2> b.
b



/ Raimo Niskanen, Erlang/OTP, Ericsson AB



Joe Armstrong wrote:
>
>  Try typing the following:
>
> > 1.0e309.
>
>  Is this a bug?
>
>  /Joe
>



Reply | Threaded
Open this post in threaded view
|

Bug ... in Erlang

Einar Karttunen
On 18.06 14:19, Raimo Niskanen wrote:
> So, list_to_float/1 has been rewritten to use strtod() (previously
> atof() on Unixish systems and sscanf("%lf",..) on Windows) and check
> errors on all platforms. Hopefully no more malicious floats.
>

I have a patch for replacing various sscanf:s with strtod / strtol,
if you are interested. Mainly a cosmetic thing, but should be a
tiny bit faster too...

ps. if you want it I can send it to the patches list.

- Einar Karttunen


Reply | Threaded
Open this post in threaded view
|

Bug ... in Erlang

Raimo Niskanen-7
Why not, go ahead. It will not be included in R9C, though.

/ Raimo Niskanen, Erlang/OTP, Ericsson AB



Einar Karttunen wrote:

> On 18.06 14:19, Raimo Niskanen wrote:
>
>>So, list_to_float/1 has been rewritten to use strtod() (previously
>>atof() on Unixish systems and sscanf("%lf",..) on Windows) and check
>>errors on all platforms. Hopefully no more malicious floats.
>>
>
>
> I have a patch for replacing various sscanf:s with strtod / strtol,
> if you are interested. Mainly a cosmetic thing, but should be a
> tiny bit faster too...
>
> ps. if you want it I can send it to the patches list.
>
> - Einar Karttunen