erlang/otp

Corrupted beam file with maybe and some optimisations disabled

RobinMorisset opened this issue · 1 comments

Describe the bug
Running the following commands:

erlc +no_copt +no_bool_opt +no_ssa_opt -W0 ~/minimized/beam_crash.erl
erl -noshell -pa . -s beam_crash wrapper0 -s init stop

with the following file at location ~/minimized/beam_crash.erl:

f1() -> 
    maybe 
        [_ | _] ?= ((true xor true) andalso foo),
        bar ?= ?MODULE:f1()
    end.

wrapper0() -> 
    ok.

results in the following error message:

Error! Failed to load module 'beam_crash' because it requires a more recent Erlang/OTP version or its .beam file was corrupted.
(You are running Erlang/OTP 26.)

Runtime terminating during boot ({undef,[{init,start_it,1,[]},{init,start_em,1,[]},{init,do_boot,3,[]}]})

Crash dump is being written to: erl_crash.dump...done

Affected versions
master

Additional context
This crash is 100% reproducible, but disappears if any of the three disabled optimizations is re-enabled.

bjorng commented

Thanks! The linked pull request resolves the issue.