File 0430-Fix-crash-in-beam_bool.patch of Package erlang

From 1ee690bef4c44eeb72c958a517a156cfb45600b7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org>
Date: Tue, 26 Jul 2022 13:12:36 +0200
Subject: [PATCH] Fix crash in beam_bool

Fixes #6164
---
 lib/compiler/src/beam_ssa_bool.erl |  7 +++++--
 lib/compiler/test/guard_SUITE.erl  | 18 ++++++++++++++++++
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/lib/compiler/src/beam_ssa_bool.erl b/lib/compiler/src/beam_ssa_bool.erl
index 6efab4fd07..7a7209e197 100644
--- a/lib/compiler/src/beam_ssa_bool.erl
+++ b/lib/compiler/src/beam_ssa_bool.erl
@@ -1066,10 +1066,13 @@ redirect_test(Bool, SuccFail, G0, St) ->
 redirect_test_1(V, SuccFail, G) ->
     case get_targets(V, G) of
         {br,_Succ,Fail} ->
-            %% I have only seen this happen in code generated by LFE
-            %% (in lfe_andor_SUITE.core and lfe_guard_SUITE.core)
+            %% This is rare when compiling from Erlang code. It is
+            %% more frequent for generated by another code generator
+            %% such as the one in LFE (see lfe_andor_SUITE.core and
+            %% lfe_guard_SUITE.core).
             case SuccFail of
                 {fail,Fail} -> G;
+                {fail,_} -> not_possible();
                 {succ,_} -> not_possible()
             end;
         {br,Next} ->
diff --git a/lib/compiler/test/guard_SUITE.erl b/lib/compiler/test/guard_SUITE.erl
index ba89255e7b..9664b4cbfd 100644
--- a/lib/compiler/test/guard_SUITE.erl
+++ b/lib/compiler/test/guard_SUITE.erl
@@ -2547,6 +2547,7 @@ beam_bool_SUITE(_Config) ->
     gh4788(),
     beam_ssa_bool_coverage(),
     bad_map_in_guard(),
+    gh_6164(),
     gh_7252(),
     ok.
 
@@ -3058,6 +3059,23 @@ beam_ssa_bool_coverage_1(V) when V andalso 0, tuple_size(0) ->
 beam_ssa_bool_coverage_1(_) ->
     error.
 
+gh_6164() ->
+    true = do_gh_6164(id([])),
+    {'EXIT',{{case_clause,42},_}} = catch do_gh_6164(id(0)),
+
+    ok.
+
+do_gh_6164(V1) ->
+    case 42 of
+        V2 ->
+            case is_list(V1) of
+                V3 ->
+                    case V3 orelse V2 of
+                        _ when V3 -> 100
+                    end =< V3
+            end
+    end.
+
 -record(bad_map_in_guard, {name}).
 bad_map_in_guard() ->
     error = bad_map_in_guard_1().
-- 
2.35.3

openSUSE Build Service is sponsored by