<html><head></head><body><div style="color:#000; background-color:#fff; font-family:Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:13px"><div id="yui_3_16_0_ym19_1_1519912327569_292655" dir="ltr"><span id="yui_3_16_0_ym19_1_1519912327569_292660">I realize my mistake right after sending out. Indeed its related to this, on Windows and OSX you can load two different versions of same lib just fine. On Linux, they symbols will be taken from first loaded lib, and second loaded lib will call symbols from the first loaded lib if the signatures are the same! This was the reason I had erroneous behavior and random segfaults.</span></div> <div class="qtdSeparateBR" id="yui_3_16_0_ym19_1_1519912327569_292717"><br><br></div><div class="yahoo_quoted" id="yui_3_16_0_ym19_1_1519912327569_292721" style="display: block;"> <div style="font-family: Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 13px;" id="yui_3_16_0_ym19_1_1519912327569_292720"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1519912327569_292719"> <div dir="ltr" id="yui_3_16_0_ym19_1_1519912327569_292718"><font size="2" face="Arial" id="yui_3_16_0_ym19_1_1519912327569_292723"> On Sunday, March 4, 2018 4:30 AM, Loïc Hoguin <essen@ninenines.eu> wrote:<br></font></div> <br><br> <div class="y_msg_container" id="yui_3_16_0_ym19_1_1519912327569_292848"><div dir="ltr" id="yui_3_16_0_ym19_1_1519912327569_292847">If that's on OSX you need the -dynamiclib flag, otherwise functions with <br clear="none">the same name will get overwritten when the second library is loaded, <br clear="none">and this can result in this kind of behavior.<br clear="none"><div class="yqt5189397881" id="yqtfd30855"><br clear="none">On 03/04/2018 04:20 AM, Vans S wrote:<br clear="none">> When I load more than 2 nifs in an app, I get total undefined defined <br clear="none">> behavior depending which nif loaded first. Like everything is totally <br clear="none">> messed up.<br clear="none">> <br clear="none">> Example:<br clear="none">> <br clear="none">> LD_PRELOAD="/nif1,so /nif2.so" rebar3 shell<br clear="none">> <br clear="none">> nif1 works, nif2 is totally messed ,and randomly segfaults or gives <br clear="none">> errorneous results.<br clear="none">> <br clear="none">> LD_PRELOAD="/nif2,so /nif1.so" rebar3 shell<br clear="none">> <br clear="none">> Now nif2 works, and nif1 is erroneous.<br clear="none">> <br clear="none">> <br clear="none">> Iv noticed this behavior before I recall, but now its resulted in so <br clear="none">> much frustration. Things were crashing in C++ boost side like<br clear="none">> <br clear="none">> mystruct v = boost::value_initialized<decltype(v)>();<br clear="none">> <br clear="none">> Crash here with "terminate called after throwing an instance of <br clear="none">> 'std::bad_alloc'". Switch the order of the nifs and it works fine.</div><br clear="none">> <br clear="none">> <br clear="none">> _______________________________________________<br clear="none">> erlang-questions mailing list<br clear="none">> <a shape="rect" ymailto="mailto:erlang-questions@erlang.org" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br clear="none">> <a shape="rect" href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br clear="none">> <br clear="none"><br clear="none">-- <br clear="none">Loïc Hoguin<br clear="none"><a shape="rect" href="https://ninenines.eu/" target="_blank">https://ninenines.eu</a><div class="yqt5189397881" id="yqtfd65553"><br clear="none"></div></div><br><br></div> </div> </div> </div></div></body></html>