[erlang-bugs] Compiler bug on R15B03
Loïc Hoguin
essen@REDACTED
Mon Dec 17 13:24:18 CET 2012
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.
Thanks.
> % erlc -S src/bank_mysql.erl
> % erlc bank_mysql.S
> Function: connect/5
> bank_mysql.S:none: internal error in beam_block;
> crash reason: {{case_clause,
> {'EXIT',
> {function_clause,
> [{beam_utils,live_opt,
> [[{init,{y,0}},{allocate,4,5},{label,2}],
> 31,
> {10,
> {8,1,
> {6,1,
> {1,31,nil,{5,1,{4,0,{3,0,nil,nil},nil},nil}},
> {7,1,nil,nil}},
> {10,1,{9,1,nil,nil},{11,1,nil,nil}}}},
> [{block,
> [{'%live',5},
> {set,[{y,3}],[{x,2}],move},
> {set,
> [{x,2}],
> [{literal,[binary,{active,false},{packet,raw}]}],
> move},
> {set,[{y,1}],[{x,4}],move},
> {set,[{y,2}],[{x,3}],move},
> {'%live',3}]},
> {line,[{location,"src/bank_mysql.erl",158}]},
> {call_ext,3,{extfunc,gen_tcp,connect,3}},
> {test,is_tuple,{f,5},[{x,0}]},
> {test,test_arity,{f,5},[{x,0},2]},
> {block,
> [{'%live',1},
> {set,[{x,1}],[{x,0}],{get_tuple_element,0}},
> {set,[{x,2}],[{x,0}],{get_tuple_element,1}},
> {'%live',3}]},
> {test,is_eq_exact,{f,5},[{x,1},{atom,ok}]},
> {block,
> [{'%live',3},
> {set,[],[],{alloc,3,{nozero,nostack,9,[]}}},
> {set,[{x,0}],[],{put_tuple,8}},
> {set,[],[{atom,mysql_client}],put},
> {set,[],[{x,2}],put},
> {set,[],[{literal,<<>>}],put},
> {set,[],[{integer,0}],put},
> {set,[],[{atom,ready}],put},
> {set,[],[nil],put},
> {set,[],[{integer,5000}],put},
> {set,[],[{integer,100000}],put},
> {'%live',1}]},
> {line,[{location,"src/bank_mysql.erl",161}]},
> {call,1,{f,264}},
> {test,is_tuple,{f,6},[{x,0}]},
> {test,test_arity,{f,6},[{x,0},3]},
> {block,
> [{'%live',1},
> {set,[{x,1}],[{x,0}],{get_tuple_element,0}},
> {set,[{x,2}],[{x,0}],{get_tuple_element,1}},
> {set,[{x,3}],[{x,0}],{get_tuple_element,2}},
> {'%live',4}]},
> {test,is_eq_exact,{f,6},[{x,1},{atom,ok}]},
> {block,
> [{'%live',4},
> {set,[{x,0}],[{x,2}],move},
> {set,[{y,0}],[{x,3}],move},
> {'%live',1}]},
> {line,[{location,"src/bank_mysql.erl",163}]},
> {call,1,{f,68}},
> {test,is_tuple,{f,7},[{x,0}]},
> {test,test_arity,{f,7},[{x,0},9]},
> {block,
> [{'%live',1},
> {set,[{x,1}],[{x,0}],{get_tuple_element,0}},
> {set,[{x,2}],[{x,0}],{get_tuple_element,4}},
> {set,[{x,3}],[{x,0}],{get_tuple_element,6}},
> {'%live',4}]},
> {test,is_eq_exact,{f,7},[{x,1},{atom,ok}]},
> {block,
> [{'%live',4},
> {set,[{x,4}],[{x,3}],move},
> {set,[{x,3}],[{x,2}],move},
> {set,[{x,2}],[{y,1}],move},
> {set,[{x,1}],[{y,2}],move},
> {set,[{x,5}],[{y,0}],move},
> {set,[{x,0}],[{y,3}],move},
> {'%live',6}]},
> {kill,{y,0}},
> {kill,{y,1}},
> {kill,{y,2}},
> {kill,{y,3}},
> {line,[{location,"src/bank_mysql.erl",164}]},
> {call,6,{f,183}},
> {test,is_tuple,{f,8},[{x,0}]},
> {test,test_arity,{f,8},[{x,0},2]},
> {block,
> [{'%live',1},
> {set,[{x,1}],[{x,0}],{get_tuple_element,0}},
> {set,[{x,2}],[{x,0}],{get_tuple_element,1}},
> {'%live',3}]},
> {test,is_eq_exact,{f,8},[{x,1},{atom,ok}]},
> {block,
>
> [{'%live',3},{set,[{x,0}],[{x,2}],move},{'%live',1}]},
> {line,[{location,"src/bank_mysql.erl",166}]},
> {call,1,{f,264}},
> {test,is_tuple,{f,9},[{x,0}]},
> {test,test_arity,{f,9},[{x,0},3]},
> {block,
> [{'%live',1},
> {set,[{x,1}],[{x,0}],{get_tuple_element,0}},
> {set,[{x,2}],[{x,0}],{get_tuple_element,1}},
> {set,[{x,3}],[{x,0}],{get_tuple_element,2}},
> {'%live',4}]},
> {test,is_eq_exact,{f,9},[{x,1},{atom,ok}]},
> {block,
> [{'%live',4},
> {set,[{x,0}],[{x,2}],move},
> {set,[{y,2}],[{x,3}],move},
> {set,[{y,3}],[{x,0}],move},
> {'%live',1}]},
> {line,[{location,"src/bank_mysql.erl",167}]},
> {call,1,{f,62}},
> {test,is_atom,{f,10},[{x,0}]},
> {select_val,
> {x,0},
> {f,10},
> {list,[{atom,error},{f,3},{atom,ok},{f,4}]}},
> {label,3},
> {block,
>
> [{'%live',0},{set,[{x,0}],[{y,3}],move},{'%live',1}]},
> {call_last,1,{f,168},4},
> {label,4},
> {block,
>
> [{'%live',0},{set,[{x,0}],[{y,3}],move},{'%live',1}]},
> {kill,{y,3}},
> {line,[{location,"src/bank_mysql.erl",169}]},
> {call,1,{f,74}},
> {test,is_tuple,{f,11},[{x,0}]},
> {test,test_arity,{f,11},[{x,0},6]},
> {block,
> [{'%live',1},
> {set,[{x,1}],[{x,0}],{get_tuple_element,0}},
> {set,[{x,2}],[{x,0}],{get_tuple_element,1}},
> {set,[{x,3}],[{x,0}],{get_tuple_element,2}},
> {set,[{x,4}],[{x,0}],{get_tuple_element,4}},
> {set,[{x,5}],[{x,0}],{get_tuple_element,5}},
> {'%live',6}]},
> {test,is_eq_exact,{f,11},[{x,1},{atom,ok}]},
> {test,is_eq_exact,{f,11},[{x,2},{integer,0}]},
> {test,is_eq_exact,{f,11},[{x,3},{integer,0}]},
> {test,is_eq_exact,{f,11},[{x,4},{integer,0}]},
> {test,is_eq_exact,{f,11},[{x,5},{literal,<<>>}]},
> {block,
> [{'%live',0},
> {set,[],[],{alloc,0,{nozero,nostack,3,[]}}},
> {set,[{x,0}],[],{put_tuple,2}},
> {set,[],[{atom,ok}],put},
> {set,[],[{y,2}],put},
> {'%live',1}]},
> {deallocate,4},
> return,
> {label,5},
> {line,[{location,"src/bank_mysql.erl",158}]},
> {badmatch,{x,0}},
> {label,6},
> {line,[{location,"src/bank_mysql.erl",161}]},
> {badmatch,{x,0}},
> {label,7},
> {line,[{location,"src/bank_mysql.erl",163}]},
> {badmatch,{x,0}},
> {label,8},
> {line,[{location,"src/bank_mysql.erl",164}]},
> {badmatch,{x,0}},
> {label,9},
> {line,[{location,"src/bank_mysql.erl",166}]},
> {badmatch,{x,0}},
> {label,10},
> {line,[{location,"src/bank_mysql.erl",167}]},
> {case_end,{x,0}},
> {label,11},
> {line,[{location,"src/bank_mysql.erl",169}]},
> {badmatch,{x,0}}]],
> [{file,"beam_utils.erl"},{line,654}]},
> {beam_utils,live_opt,1,
> [{file,"beam_utils.erl"},{line,205}]},
>
> {beam_block,function,2,[{file,"beam_block.erl"},{line,41}]},
> {lists,mapfoldl,3,[{file,"lists.erl"},{line,1278}]},
>
> {beam_block,module,2,[{file,"beam_block.erl"},{line,29}]},
> {compile,'-select_passes/2-anonymous-2-',2,
> [{file,"compile.erl"},{line,473}]},
> {compile,'-internal_comp/4-anonymous-1-',2,
> [{file,"compile.erl"},{line,273}]},
>
> {compile,fold_comp,3,[{file,"compile.erl"},{line,291}]}]}}},
> [{compile,'-select_passes/2-anonymous-2-',2,
> [{file,"compile.erl"},{line,473}]},
> {compile,'-internal_comp/4-anonymous-1-',2,
> [{file,"compile.erl"},{line,273}]},
> {compile,fold_comp,3,[{file,"compile.erl"},{line,291}]},
>
> {compile,internal_comp,4,[{file,"compile.erl"},{line,275}]},
> {compile,'-do_compile/2-anonymous-0-',2,
> [{file,"compile.erl"},{line,152}]}]}
>
> I'm even more lost with that.
>
> Can you please tell me if you can reproduce this? Hope I can help get
> this resolved.
>
> Thanks.
>
--
Loïc Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu
More information about the erlang-bugs
mailing list