diff options
Diffstat (limited to 'erts/emulator/test/code_SUITE.erl')
-rw-r--r-- | erts/emulator/test/code_SUITE.erl | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/erts/emulator/test/code_SUITE.erl b/erts/emulator/test/code_SUITE.erl index 020065f6d8..a1e63cd36c 100644 --- a/erts/emulator/test/code_SUITE.erl +++ b/erts/emulator/test/code_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1999-2021. All Rights Reserved. +%% Copyright Ericsson AB 1999-2023. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -33,8 +33,9 @@ false_dependency/1,coverage/1,fun_confusion/1, t_copy_literals/1, t_copy_literals_frags/1, erl_544/1, max_heap_size/1, - check_process_code_signal_order/1, - check_process_code_dirty_exec_proc/1]). + check_process_code_signal_order/1, + check_process_code_dirty_exec_proc/1, + call_fun_before_load/1]). -define(line_trace, 1). -include_lib("common_test/include/ct.hrl"). @@ -52,7 +53,7 @@ all() -> false_dependency, coverage, fun_confusion, t_copy_literals, t_copy_literals_frags, erl_544, max_heap_size, check_process_code_signal_order, - check_process_code_dirty_exec_proc]. + check_process_code_dirty_exec_proc, call_fun_before_load]. init_per_suite(Config) -> erts_debug:set_internal_state(available_internal_state, true), @@ -1184,6 +1185,29 @@ check_process_code_dirty_exec_proc(Config) when is_list(Config) -> false = is_process_alive(Pid), ok. +%% OTP-18016: When loading a module over itself, a race in fun loading made it +%% possible to call a local fun before the module was fully reloaded. +call_fun_before_load(Config) -> + Priv = proplists:get_value(priv_dir, Config), + Data = proplists:get_value(data_dir, Config), + Path = code:get_path(), + true = code:add_path(Priv), + try + SrcFile = filename:join(Data, "call_fun_before_load.erl"), + ObjFile = filename:join(Priv, "call_fun_before_load.beam"), + {ok,Mod,Code} = compile:file(SrcFile, [binary, report]), + {module,Mod} = code:load_binary(Mod, ObjFile, Code), + + ok = call_fun_before_load:run(ObjFile, Code), + + code:purge(call_fun_before_load) + after + code:set_path(Path), + code:delete(call_fun_before_load), + code:purge(call_fun_before_load) + end, + ok. + %% Utilities. make_sub_binary(Bin) when is_binary(Bin) -> |