bug in string:copies when copying float times character
PAILLEAU Eric
eric.pailleau@REDACTED
Sun Oct 24 13:02:36 CEST 2010
Hello,
I found something weird, that can be considered as a bug.
Here is below the documentation for string:copies function.
---------------------------------------
copies(String, Number) -> Copies
Types:
String = Copies = string()
Number = integer()
---------------------------------------
Number should obviously be an integer, but it seems there no
guards on the type.
I forgot do round my copy number of characters, I got crashes, and I
finally found the problem :
by doing :
--------------------------------------------------------------------
Erlang R14A (erts-5.8) [source] [smp:2:2] [rq:2] [async-threads:0]
[hipe] [kernel-poll:false]
Eshell V5.8 (abort with ^G)
1> string:copies("a",2.5).
Crash dump was written to: erl_crash.dump
eheap_alloc: Cannot allocate 1140328500 bytes of memory (of type "heap").
--------------------------------------------------------------------
Erlang try to allocate the whole memory when trying to copy any float
number of characters. My computer is frozen a while, and reach hopefully
to garbage .
I got same behaviour in R13 and I did update to R14 in order to see if a
fix was done.
I guess an en exception 'badarith' or something else should be raised if
integer is not used on such function.
Best regards.
More information about the erlang-bugs
mailing list