Erlang/OTP Forums

Author Message

<  Erlang bugs mailing list  ~  bug in string:copies when copying float times character

Guest
Posted: Fri Oct 29, 2010 6:42 am Reply with quote
Guest
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.Cool [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.










________________________________________________________________
erlang-bugs (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-bugs-unsubscribe@erlang.org

Post received from mailinglist

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum