<div dir="ltr"><div><div>Hello, <br><br></div>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.<br><br></div><div>Unfortunatly this seems no longer working in OTP 20 as time : In embedded mode, first all modules are loaded.
Then all <span class="gmail-code">on_load</span> functions are called. The system is
terminated unless all of the <span class="gmail-code">on_load</span> functions return
<span class="gmail-code">ok</span>.<br><br></div><div>My stub is as follow:<br></div><div><br><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9pt">-module(erlpool_globals)<span style="color:rgb(0,0,128);font-weight:bold">.<br></span><span style="color:rgb(0,0,128);font-weight:bold"><br></span><span style="color:rgb(128,128,128);font-style:italic">%% Module stub.<br></span><span style="color:rgb(128,128,128);font-style:italic">%% Will be replaced by the module with the same name at runtime.<br></span><span style="color:rgb(128,128,128);font-style:italic">%% The only purpose for the module is to suppress warnings from code analyzers,<br></span><span style="color:rgb(128,128,128);font-style:italic">%% as dynamically compiled module is not available during the build.<br></span><span style="color:rgb(128,128,128);font-style:italic"><br></span>-export([])<span style="color:rgb(0,0,128);font-weight:bold">.<br></span><span style="color:rgb(0,0,128);font-weight:bold"><br></span>-on_load(do_not_load/<span style="color:rgb(0,0,255)">0</span>)<span style="color:rgb(0,0,128);font-weight:bold">.<br></span><span style="color:rgb(0,0,128);font-weight:bold"><br></span>do_not_load() -><br> do_not_load<span style="color:rgb(0,0,128);font-weight:bold">.</span></pre><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9pt">In OTP < 20 works fine. In 20 is not. The app crashes at startup if the relase is done using <br>{profile, standalone}, or {profile, embedded}<br><br></pre><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9pt">Any workarounds ?<br><br></pre><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9pt">Silviu<br></pre><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9pt"><span style="color:rgb(0,0,128);font-weight:bold"></span></pre></div></div>