fix crash in hipe_icode_exceptions
Mikael Pettersson
mikpe@REDACTED
Fri Aug 27 22:00:53 CEST 2010
This fixes a problem in the HiPE compiler's BEAM-to-Icode
pass where it can crash due to the BEAM compiler's merging
of identical basic blocks with different exception handling
contexts. This bug has been latent, but is now exposed by
what appears to be more aggressive optimizations in BEAM.
The added comment explains things in more detail.
/Mikael
--- otp_src_R14A/lib/hipe/icode/hipe_icode_exceptions.erl.~1~ 2009-09-18 16:08:48.000000000 +0200
+++ otp_src_R14A/lib/hipe/icode/hipe_icode_exceptions.erl 2010-08-27 21:09:34.000000000 +0200
@@ -344,6 +344,16 @@ pop_catch(Cs) ->
pop_catch_1([[_|C] | Cs]) ->
[C | pop_catch_1(Cs)];
+pop_catch_1([[] | Cs]) ->
+ %% The elements in the list represent different possible incoming
+ %% stacks of catch handlers to this BB. Before the fixpoint has
+ %% been found these elements are underapproximations of the true
+ %% stacks, therefore it's possible for these elements to be too
+ %% short for the number of pops implied by the code in the BB.
+ %% We must not fail in that case, so we set pop([]) = [].
+ %% This fixes find_catches_crash.erl and compiler_tests in the
+ %% HiPE test suite.
+ [[] | pop_catch_1(Cs)];
pop_catch_1([]) ->
[].
More information about the erlang-patches
mailing list