File 0497-Fix-internal-consistency-failure-for-is_function-2.patch of Package erlang
From 8be2c32fe0534d863c6ce6d7665011a162fc39ec Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org>
Date: Tue, 20 Nov 2018 13:05:51 +0100
Subject: [PATCH] Fix internal consistency failure for is_function/2
There could be an internal consistency failure when using is_function/2,
because an optimization did not take into account that is_function/2 can fail.
https://bugs.erlang.org/browse/ERL-778
---
lib/compiler/src/beam_utils.erl | 5 ++++-
lib/compiler/test/beam_utils_SUITE.erl | 23 +++++++++++++++++++++--
2 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/lib/compiler/src/beam_utils.erl b/lib/compiler/src/beam_utils.erl
index 6e23003fc7..6b2ab5a2a4 100644
--- a/lib/compiler/src/beam_utils.erl
+++ b/lib/compiler/src/beam_utils.erl
@@ -589,7 +589,9 @@ check_liveness_block_2(R, {gc_bif,Op,{f,Lbl}}, Ss, St) ->
check_liveness_fail(R, Op, Args, Fail, St) ->
Arity = length(Args),
+ %% Note that is_function/2 is a type test but is not safe.
case erl_internal:comp_op(Op, Arity) orelse
- erl_internal:new_type_test(Op, Arity) of
+ (erl_internal:new_type_test(Op, Arity) andalso
+ erl_bifs:is_safe(erlang, Op, Arity)) of
true -> {killed,St};
false -> check_liveness_at(R, Fail, St)
end.
--
2.16.4