[erlang-bugs] R14B04 and R15A: Possible bug when compiling code using binary expressions with hipe

Magnus Klaar magnus.klaar@REDACTED
Fri Dec 9 22:34:45 CET 2011


Hi!

We found some code that successfully compiles to bytecode and behaves as
expected using the beam interpreter but fails to compile using the hipe
compiler. The code in questions is the 'cowboy_http' module in the cowboy
web server. The code is available to browse online at
https://github.com/extend/cowboy

The module contains many occurances of <<..., Var/bits>> patterns.
Replacing all occurances of "bits" with "binary" solves the problem. I
tried this because the code is only working on character strings, matching
out bitstrings doesn't make much sense to begin with. I have reproduced the
error on 64bit builds of the R14B04 and R15A releases under GNU/Linux
(Debian wheezy). I did not try older releases to check if it is a new issue.

To reproduce the error. Execute the following steps on a system with either
one of these releases installed. I'm using R15A here because the line
numbers in the error messages are pretty useful to include in a bug report.
(thanks for this addition of line numbers in R15).

1. Download, compile and run tests using bytecode interpreter
git clone git://github.com/extend/cowboy.git
cd cowboy
git checkout 168405830d564ff87fac61bd990c17ab6a35dfa8 # in case the code is
updated

rebar get-deps
rebar compile
rebar eunit skip_deps=true

2. Add native to the erl_opts parameter list in rebar.config
vim rebar.config # add it under warn_export_all

3. Recompile using hipe
rebar clean
rebar compile


4. Expect an output containing these error messages

==> cowboy (compile)
Compiled src/cowboy_http_handler.erl
Compiled src/cowboy_http_websocket_handler.erl
Compiled src/cowboy_protocol.erl
Compiled src/cowboy.erl
Compiled src/cowboy_app.erl
Compiled src/cowboy_acceptors_sup.erl
Compiled src/cowboy_acceptor.erl
Compiled src/cowboy_bstr.erl
Compiled src/cowboy_dispatcher.erl
<HiPE (v 3.8.1.pre)> EXITED with reason
{function_clause,[{hipe_rtl_binary_match,gen_rtl,[{bs_match_string,<<34>>,1},[],[{rtl_var,21}],17,6],[{file,[104,105,112,101,95,114,116,108,95,98,105,110,97,114,121,95,109,97,116,99,104,46,101,114,108]},{line,45}]},{hipe_rtl_binary,gen_rtl,7,[{file,[104,105,112,101,95,114,116,108,95,98,105,110,97,114,121,46,101,114,108]},{line,33}]},{hipe_rtl_primops,gen_primop,3,[{file,[104,105,112,101,95,114,116,108,95,112,114,105,109,111,112,115,46,101,114,108]},{line,147}]},{hipe_icode2rtl,gen_call,3,[{file,[104,105,112,101,95,105,99,111,100,101,50,114,116,108,46,101,114,108]},{line,189}]},{hipe_icode2rtl,translate_instrs,5,[{file,[104,105,112,101,95,105,99,111,100,101,50,114,116,108,46,101,114,108]},{line,104}]},{hipe_icode2rtl,translate,2,[{file,[104,105,112,101,95,105,99,111,100,101,50,114,116,108,46,101,114,108]},{line,71}]},{hipe_main,translate_to_rtl,2,[{file,[104,105,112,101,95,109,97,105,110,46,101,114,108]},{line,396}]},{hipe_main,icode_to_rtl,4,[{file,[104,105,112,101,95,109,97,105,110,46,101,114,108]},{line,376}]}]}
@hipe:867

=ERROR REPORT==== 9-Dec-2011::22:18:06 ===
<HiPE (v 3.8.1.pre)> Error: [hipe:866]: ERROR: {function_clause,
                                                [{hipe_rtl_binary_match,
                                                  gen_rtl,

[{bs_match_string,<<"\"">>,
                                                    1},
                                                   [],
                                                   [{rtl_var,21}],
                                                   17,6],
                                                  [{file,

"hipe_rtl_binary_match.erl"},
                                                   {line,45}]},
                                                 {hipe_rtl_binary,gen_rtl,7,
                                                  [{file,
                                                    "hipe_rtl_binary.erl"},
                                                   {line,33}]},
                                                 {hipe_rtl_primops,
                                                  gen_primop,3,
                                                  [{file,
                                                    "hipe_rtl_primops.erl"},
                                                   {line,147}]},
                                                 {hipe_icode2rtl,gen_call,3,

[{file,"hipe_icode2rtl.erl"},
                                                   {line,189}]},
                                                 {hipe_icode2rtl,
                                                  translate_instrs,5,

[{file,"hipe_icode2rtl.erl"},
                                                   {line,104}]},

 {hipe_icode2rtl,translate,2,

[{file,"hipe_icode2rtl.erl"},
                                                   {line,71}]},

 {hipe_main,translate_to_rtl,
                                                  2,
                                                  [{file,"hipe_main.erl"},
                                                   {line,396}]},
                                                 {hipe_main,icode_to_rtl,4,
                                                  [{file,"hipe_main.erl"},
                                                   {line,376}]}]}

=ERROR REPORT==== 9-Dec-2011::22:18:06 ===
Error in process <0.788.0> with exit value:
{{hipe,867,{function_clause,[{hipe_rtl_binary_match,gen_rtl,[{bs_match_string,<<1
byte>>,1},[],[{rtl_var,21}],17,6],[{file,"hipe_rtl_binary_match.erl"},{line,45}]},{hipe_rtl_binary,gen_rtl,7,[{file,"hipe_rtl_binary.erl"},{line,33}]},{hipe_rtl_primops...

src/cowboy_http.erl:none: internal error in native_compile;
crash reason: {{hipe,867,
                   {function_clause,
                       [{hipe_rtl_binary_match,gen_rtl,
                            [{bs_match_string,<<"\"">>,1},
                             [],
                             [{rtl_var,21}],
                             17,6],
                            [{file,"hipe_rtl_binary_match.erl"},{line,45}]},
                        {hipe_rtl_binary,gen_rtl,7,
                            [{file,"hipe_rtl_binary.erl"},{line,33}]},
                        {hipe_rtl_primops,gen_primop,3,
                            [{file,"hipe_rtl_primops.erl"},{line,147}]},
                        {hipe_icode2rtl,gen_call,3,
                            [{file,"hipe_icode2rtl.erl"},{line,189}]},
                        {hipe_icode2rtl,translate_instrs,5,
                            [{file,"hipe_icode2rtl.erl"},{line,104}]},
                        {hipe_icode2rtl,translate,2,
                            [{file,"hipe_icode2rtl.erl"},{line,71}]},
                        {hipe_main,translate_to_rtl,2,
                            [{file,"hipe_main.erl"},{line,396}]},
                        {hipe_main,icode_to_rtl,4,
                            [{file,"hipe_main.erl"},{line,376}]}]}},
               [{hipe,finalize_fun_sequential,3,
                    [{file,"hipe.erl"},{line,867}]},
                {hipe,'-finalize_fun_concurrent/3-fun-3-',4,
                    [{file,"hipe.erl"},{line,833}]}]}


I hope this is enough information to reproduce the issue once it hits
someones desk at the other side of the internet.

/ Magnus Klaar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20111209/6204cf4e/attachment.htm>


More information about the erlang-bugs mailing list