[erlang-bugs] Fix renaming of bs_put_string instructions

Anthony Ramine n.oxyde@REDACTED
Fri May 24 21:10:42 CEST 2013


Hello,

If an Erlang module is compiled to BEAM assembly and the result contains a bs_put_string instruction, the output can't be compiled to binary anymore and the compiler crashes with the following error:

$ erlc prs.S
Function: compress/1
prs.S:none: internal error in beam_block;
crash reason: {{case_clause,
                   {'EXIT',
                       {function_clause,
                           [{beam_utils,live_opt,
                                [[{bs_put_string,1,{string,[0]}},
                                  {bs_init,
                                      {f,0},
                                      {bs_append,0,8,{field_flags,[]}},
                                      0,
                                      [{integer,8},{x,0}],
                                      {x,1}},
                                  {label,2}],
                                 2,
                                 {1,{1,1,nil,nil}},
                                 [{block,
                                      [{'%live',2},
                                       {set,[{x,0}],[{x,1}],move},
                                       {'%live',1}]},
                                  return]],
                                [{file,"beam_utils.erl"},{line,639}]},
                            {beam_utils,live_opt,1,
                                [{file,"beam_utils.erl"},{line,205}]},
                            {beam_block,function,2,
                                [{file,"beam_block.erl"},{line,38}]},
                            {lists,mapfoldl,3,
                                [{file,"lists.erl"},{line,1329}]},
                            {beam_block,module,2,
                                [{file,"beam_block.erl"},{line,29}]},
                            {compile,'-select_passes/2-anonymous-2-',2,
                                [{file,"compile.erl"},{line,476}]},
                            {compile,'-internal_comp/4-anonymous-1-',2,
                                [{file,"compile.erl"},{line,276}]},
                            {compile,fold_comp,3,
                                [{file,"compile.erl"},{line,294}]}]}}},
               [{compile,'-select_passes/2-anonymous-2-',2,
                    [{file,"compile.erl"},{line,476}]},
                {compile,'-internal_comp/4-anonymous-1-',2,
                    [{file,"compile.erl"},{line,276}]},
                {compile,fold_comp,3,[{file,"compile.erl"},{line,294}]},
                {compile,internal_comp,4,[{file,"compile.erl"},{line,278}]},
                {compile,'-do_compile/2-anonymous-0-',2,
                    [{file,"compile.erl"},{line,152}]}]}


The clause was probably commented-out because at this point in the code, no bs_put_string instruction has been generated yet when compiling from Erlang.

This bug was reported by Loïc Hoguin.

	git fetch https://github.com/nox/otp.git fix-bs_put_string-renaming

	https://github.com/nox/otp/compare/erlang:maint...fix-bs_put_string-renaming
	https://github.com/nox/otp/compare/erlang:maint...fix-bs_put_string-renaming.patch

Regards,

-- 
Anthony Ramine




More information about the erlang-bugs mailing list