[erlang-patches] Fix error in beam_disasm if no attributes chunk found in beam files

Haitao Li lihaitao@REDACTED
Fri Jul 22 11:39:25 CEST 2011


Hi,

How to reproduce:

$ erl
1> c(abc).
{ok,abc}
2> beam_lib:strip(abc).
{ok,{abc,"abc.beam"}}
3> beam_disasm:file(abc).
{error,beam_disasm,
       {internal,{{case_clause,{error,beam_lib,
                                      {missing_chunk,'abc.beam',"Attr"}}},
                  [{beam_disasm,optional_chunk,2},
                   {beam_disasm,process_chunks,1},
                   {beam_disasm,file,1},
                   {erl_eval,do_apply,5},
                   {shell,exprs,7},
                   {shell,eval_exprs,7},
                   {shell,eval_loop,3}]}}}


Patch:
git fetch git://github.com/lht/otp.git beam-disasm-chunks-badmatch

diff --git a/lib/compiler/src/beam_disasm.erl b/lib/compiler/src/beam_disasm.erl
index 017ca12..9df10e9 100644
--- a/lib/compiler/src/beam_disasm.erl
+++ b/lib/compiler/src/beam_disasm.erl
@@ -182,7 +182,7 @@ process_chunks(F) ->
            Literals = beam_disasm_literals(LiteralBin),
            Code = beam_disasm_code(CodeBin, Atoms, mk_imports(ImportsList),
                                    StrBin, Lambdas, Literals, Module),
-           Attributes = optional_chunk(F, attributes),
+           Attributes = optional_chunk(F, "Attr"),
            CompInfo =
                case optional_chunk(F, "CInf") of
                    none -> none;

Haitao



More information about the erlang-patches mailing list