From 4a59ebeb43184fb9dcdb3d2b4aeb454a2caed700 Mon Sep 17 00:00:00 2001 From: Rickard Green Date: Thu, 17 Oct 2019 16:23:56 +0200 Subject: Fix release of literal areas Literal areas could get prematurely removed and accessed from the exit reason of a terminated process, or accessed from the heap of a process executing dirty while terminating. --- erts/preloaded/src/erts_internal.erl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'erts/preloaded/src/erts_internal.erl') diff --git a/erts/preloaded/src/erts_internal.erl b/erts/preloaded/src/erts_internal.erl index 26fb1458af..6bbbf63ba6 100644 --- a/erts/preloaded/src/erts_internal.erl +++ b/erts/preloaded/src/erts_internal.erl @@ -45,7 +45,7 @@ -export([check_process_code/3]). -export([check_dirty_process_code/2]). -export([is_process_executing_dirty/1]). --export([release_literal_area_switch/0]). +-export([release_literal_area_switch/0, wait_release_literal_area_switch/1]). -export([purge_module/2]). -export([flush_monitor_messages/3]). @@ -301,6 +301,15 @@ is_process_executing_dirty(_Pid) -> release_literal_area_switch() -> erlang:nif_error(undefined). +-spec wait_release_literal_area_switch(WaitMsg) -> 'true' | 'false' when + WaitMsg :: term(). + +wait_release_literal_area_switch(WaitMsg) -> + %% release_literal_area_switch() traps to here + %% when it needs to wait + receive WaitMsg -> ok end, + erts_internal:release_literal_area_switch(). + -spec purge_module(Module, Op) -> boolean() when Module :: module(), Op :: 'prepare' | 'prepare_on_load' | 'abort' | 'complete'. -- cgit v1.2.1