Describe the bug
beam_lib:chunks/2,3 and beam_lib:md5/1 are specified to answer {ok, _} or {error, beam_lib, Reason}. For bytes whose atom chunk does not parse, extract_module/2 raises: an AtU8 chunk of no bytes, a name in it that is not UTF-8, or a name longer than the chunk. scan_beam1/2 catches the raise with catch and passes on only a tuple tagged error, so it returns the 'EXIT' tuple as a result. read_chunk_data/3's match {ok, Module, Chunks} = scan_beam(...) then raises badmatch. read_chunk_data/2 catches throws alone, so chunks/2 raises, and md5/1, which calls under catch, returns the 'EXIT' tuple.
To Reproduce
erl -noshell -eval '
Bad = <<"FOR1", 12:32, "BEAM", "AtU8", 0:32>>,
io:format("~P~n", [try beam_lib:chunks(Bad, [atoms]) catch C:R -> {raised, C, R} end, 7]),
io:format("~P~n", [beam_lib:md5(Bad), 7]),
halt().'
It prints {raised,error,{badmatch,{'EXIT',...}}} and {'EXIT',{{badmatch,{'EXIT',...}},[...]}}.
Expected behavior
Both answer {error, beam_lib, {inv
📅 Opened Nov 15, 2026💬 0 comments