[erlang-questions] on_load behaviour in OTP 20

Caragea Silviu silviu.cpp@REDACTED
Sat Jul 8 20:21:59 CEST 2017


Hello,

In some of my projects I have modules dynamically compiled. In order to
avoid static analyzers warning I had used a stub module. And also in order
to avoid when doing hot-swap releases to have the stubs reloaded and
overwriting the code I used on_load that returns something different than
ok.

Unfortunatly this seems no longer working in OTP 20 as time : In embedded
mode, first all modules are loaded. Then all on_load functions are called.
The system is terminated unless all of the on_load functions return ok.

My stub is as follow:

-module(erlpool_globals).

%% Module stub.
%% Will be replaced by the module with the same name at runtime.
%% The only purpose for the module is to suppress warnings from code analyzers,
%% as dynamically compiled module is not available during the build.

-export([]).

-on_load(do_not_load/0).

do_not_load() ->
    do_not_load.

In OTP < 20 works fine. In 20 is not. The app crashes at startup if
the relase is done using
{profile, standalone}, or  {profile, embedded}

Any workarounds ?

Silviu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170708/b5b49abe/attachment.htm>


More information about the erlang-questions mailing list