Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang
erlang
0105-Eliminate-assertion-failure-in-beam_ssa_co...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0105-Eliminate-assertion-failure-in-beam_ssa_codegen.patch of Package erlang
From bb3cfdb32447f41ac2a27b7bd413434524b17b85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org> Date: Wed, 8 Mar 2023 06:51:27 +0100 Subject: [PATCH] Eliminate assertion failure in beam_ssa_codegen If the code in `?EXCEPTION_BLOCK` is modified in any way, the `beam_ssa_codegen:assert_exception_block/1` function will cause an internal compiler error. Ensure that the literal unfolding optimization in `beam_ssa_opt` will not modify the code in `?EXCEPTION_BLOCK`. --- lib/compiler/src/beam_ssa_opt.erl | 2 ++ lib/compiler/test/beam_except_SUITE.erl | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/compiler/src/beam_ssa_opt.erl b/lib/compiler/src/beam_ssa_opt.erl index 01e1fe2c6a..851573a82b 100644 --- a/lib/compiler/src/beam_ssa_opt.erl +++ b/lib/compiler/src/beam_ssa_opt.erl @@ -3022,6 +3022,8 @@ collect_arg_literals([V|Vs], Info, X, Acc0) -> collect_arg_literals([], _Info, _X, Acc) -> Acc. +unfold_literals([?EXCEPTION_BLOCK|Ls], LitMap, SafeMap, Blocks) -> + unfold_literals(Ls, LitMap, SafeMap,Blocks); unfold_literals([L|Ls], LitMap, SafeMap0, Blocks0) -> {Blocks,Safe} = case map_get(L, SafeMap0) of diff --git a/lib/compiler/test/beam_except_SUITE.erl b/lib/compiler/test/beam_except_SUITE.erl index 9a90c1b676..c52217ad79 100644 --- a/lib/compiler/test/beam_except_SUITE.erl +++ b/lib/compiler/test/beam_except_SUITE.erl @@ -22,7 +22,7 @@ -export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, init_per_group/2,end_per_group/2, multiple_allocs/1,bs_get_tail/1,coverage/1, - binary_construction_allocation/1]). + binary_construction_allocation/1,unfold_literals/1]). suite() -> [{ct_hooks,[ts_install_cth]}]. @@ -34,7 +34,8 @@ groups() -> [multiple_allocs, bs_get_tail, coverage, - binary_construction_allocation]}]. + binary_construction_allocation, + unfold_literals]}]. init_per_suite(Config) -> test_lib:recompile(?MODULE), @@ -177,6 +178,19 @@ do_binary_construction_allocation(Req) -> _ -> ok end. +unfold_literals(_Config) -> + a = do_unfold_literals(badarg, id({a,b})), + {'EXIT',{badarg,_}} = catch do_unfold_literals(badarg, id(a)), + + ok. + +do_unfold_literals(_BadArg, T) -> + %% The call `erlang:error(badarg)` in ?EXCEPTION_BLOCK would be + %% rewritten to `erlang:error(_BadArg)` by + %% beam_ssa_opt:unfold_literals/1, which would cause + %% beam_ssa_codegen:assert_exception_block/1 to fail. + element(1, T). + id(I) -> I. -file("fake.erl", 1). -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor