[erlang-bugs] Compiler bug on R15B03

Loïc Hoguin <>
Mon Dec 17 13:52:37 CET 2012


On 12/17/2012 01:30 PM, Adam Rutkowski wrote:
>
> On 17 Dec 2012, at 13:24, Loïc Hoguin wrote:
>
>> On 12/17/2012 11:23 AM, Loïc Hoguin wrote:
>>> Hello,
>>>
>>> We have found a couple issues when compiling and executing a certain
>>> module. Reproduced on 2 machines. Mine was running ArchLinux 64bits.
>>>
>>> This file:
>>>
>>> https://raw.github.com/extend/bank_mysql/master/src/bank_mysql.erl
>>>
>>> You can compile it with -compile(export_all) to quickly test the issue.
>>> Load the beam in the R15B03 VM and then run:
>>>
>>>> bank_mysql:params_to_bin([123,21340949]).
>>>
>>> You'll get a weird failure in a clause where one of these integers
>>> appears to be a binary (line 549). That's not true though, because if
>>> you io:format/2 there nothing will appear. The code properly goes
>>> through the clause for integers.
>>>
>>> It's not related to the values, it also does it if it's something other
>>> than integers (like a datetime tuple and a binary). The
>>> closest-to-failure call reproducing this issue, found by tracing, is:
>>>
>>>> bank_mysql:params_to_bin([21340949], <<0:1>>,
>>> <<8,0>>,<<123,0,0,0,0,0,0,0,0>>).
>>>
>>> I have no idea what happens there. The line given is definitely not the
>>> right one, and the code worked fine on R15B01, no reasons it shouldn't
>>> on R15B03.
>>>
>>> Other weirdness, I wanted to try editing the .S file, adding {line,
>>> [...]} clauses in order to find exactly where it failed, but it seems I
>>> can't even compile the .S file generated at all. I get this error:
>>
>> hq1 on IRC tried a few more things and found that this is the 2nd parameter causing the crash. If it's any bitstring with a size that isn't a multiple of 8 it fails. So bitstrings are apparently broken.
>
>
> Minimal example to reproduce:
>
>
>
> -module(foo).
>
> -compile([export_all]).
>
> bar(A) ->
>      <<A/binary, 0:1>>.
>
>
>
> Erlang R15B02 (erts-5.9.2) [source] [smp:4:4] [async-threads:0] [hipe] [kernel-poll:false]
>
> Eshell V5.9.2  (abort with ^G)
> 1> c(foo).
> {ok,foo}
> 2> foo:bar(<<0:1>>).
> <<0:2>>
> 3>
>
>
> Erlang R15B03 (erts-5.9.3) [source] [smp:4:4] [async-threads:0] [hipe] [kernel-poll:false]
>
> Eshell V5.9.3  (abort with ^G)
> 1> c(foo).
> {ok,foo}
> 2> foo:bar(<<0:1>>).
> ** exception error: bad argument
>       in function  foo:bar/1 (foo.erl, line 5)

Appending what Adam and me discussed on IRC:

Likely cause: 
http://erlang.org/pipermail/erlang-bugs/2012-October/003154.html

Works if changing /binary to /bitstring. Would have liked that change in 
R16, not R15B03.

There's still two issues:
  *  The completely wrong line number for the error.
  *  The compiler not able to erlc -S bank_mysql.erl ; erlc bank_mysql.S

-- 
Loïc Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu


More information about the erlang-bugs mailing list