From 7f82eddfaa3b89f734b4d58f1de92db86e5880cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Tue, 19 Oct 2010 13:43:13 +0200 Subject: Fix hang in on_load handlers in embedded mode In embedded mode, all on_load handlers will be called after loading all modules but before starting any servers. Therefore, if an on_load handler calls any function in the code module that calls the code server (such as code:priv_dir/1), there will be a deadlock because the code server has not yet been started. Fix this problem by invoking the on_load handlers after having started most servers in the kernel application. --- lib/kernel/src/kernel.erl | 7 +++++++ .../code_SUITE_data/on_load_app-1.0/src/on_load_embedded.erl | 9 +++++++++ 2 files changed, 16 insertions(+) (limited to 'lib') diff --git a/lib/kernel/src/kernel.erl b/lib/kernel/src/kernel.erl index 92ee7b441a..d3b0f6c712 100644 --- a/lib/kernel/src/kernel.erl +++ b/lib/kernel/src/kernel.erl @@ -143,6 +143,13 @@ init(safe) -> Boot = start_boot_server(), DiskLog = start_disk_log(), Pg2 = start_pg2(), + + %% Run the on_load handlers for all modules that have been + %% loaded so far. Running them at this point means that + %% on_load handlers can safely call kernel processes + %% (and in particular call code:priv_dir/1 or code:lib_dir/1). + init:run_on_load_handlers(), + {ok, {SupFlags, Boot ++ DiskLog ++ Pg2}}. get_code_args() -> diff --git a/lib/kernel/test/code_SUITE_data/on_load_app-1.0/src/on_load_embedded.erl b/lib/kernel/test/code_SUITE_data/on_load_app-1.0/src/on_load_embedded.erl index a39332f81d..b7fdd4d9ae 100644 --- a/lib/kernel/test/code_SUITE_data/on_load_app-1.0/src/on_load_embedded.erl +++ b/lib/kernel/test/code_SUITE_data/on_load_app-1.0/src/on_load_embedded.erl @@ -3,6 +3,15 @@ -on_load(run_me/0). run_me() -> + %% An onload handler typically calls code:priv_dir/1 + %% or code:lib_dir/1, so make sure that it works. + LibDir = code:lib_dir(on_load_app), + PrivDir = code:priv_dir(on_load_app), + LibDir = filename:dirname(PrivDir), + ModPath = code:which(?MODULE), + LibDir = filename:dirname(filename:dirname(ModPath)), + + %% Start a process to remember that the on_load was called. spawn(fun() -> register(everything_is_fine, self()), receive Any -> -- cgit v1.2.3 From 1419cda9991775c51a931ef63a51da477391722c Mon Sep 17 00:00:00 2001 From: Erlang/OTP Date: Thu, 21 Oct 2010 12:09:29 +0200 Subject: Prepare release --- lib/kernel/doc/src/notes.xml | 23 +++++++++++++++++++++++ lib/kernel/vsn.mk | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/kernel/doc/src/notes.xml b/lib/kernel/doc/src/notes.xml index 9859183390..edd6ea52b0 100644 --- a/lib/kernel/doc/src/notes.xml +++ b/lib/kernel/doc/src/notes.xml @@ -30,6 +30,29 @@

This document describes the changes made to the Kernel application.

+
Kernel 2.14.1.1 + +
Fixed Bugs and Malfunctions + + +

In embedded mode, on_load handlers that called + code:priv_dir/1 or other functions in code + would hang the system. Since the crypto + application now contains an on_loader handler that calls + code:priv_dir/1, including the crypto + application in the boot file would prevent the system + from starting.

+

Also extended the -init_debug option to print + information about on_load handlers being run to + facilitate debugging.

+

+ Own Id: OTP-8902 Aux Id: seq11703

+
+
+
+ +
+
Kernel 2.14.1
Fixed Bugs and Malfunctions diff --git a/lib/kernel/vsn.mk b/lib/kernel/vsn.mk index 651d082379..802e326f7c 100644 --- a/lib/kernel/vsn.mk +++ b/lib/kernel/vsn.mk @@ -1 +1 @@ -KERNEL_VSN = 2.14.1 +KERNEL_VSN = 2.14.1.1 -- cgit v1.2.3