[erlang-questions] more than 2 nifs in an app. total screw up?

Loïc Hoguin essen@REDACTED
Sun Mar 4 10:30:51 CET 2018

If that's on OSX you need the -dynamiclib flag, otherwise functions with 
the same name will get overwritten when the second library is loaded, 
and this can result in this kind of behavior.

On 03/04/2018 04:20 AM, Vans S wrote:
> When I load more than 2 nifs in an app, I get total undefined defined 
> behavior depending which nif loaded first. Like everything is totally 
> messed up.
> Example:
> LD_PRELOAD="/nif1,so /nif2.so" rebar3 shell
> nif1 works, nif2 is totally messed ,and randomly segfaults or gives 
> errorneous results.
> LD_PRELOAD="/nif2,so /nif1.so" rebar3 shell
> Now nif2 works, and nif1 is erroneous.
> Iv noticed this behavior before I recall, but now its resulted in so 
> much frustration. Things were crashing in C++ boost side like
> mystruct v = boost::value_initialized<decltype(v)>();
> Crash here with "terminate called after throwing an instance of 
> 'std::bad_alloc'". Switch the order of the nifs and it works fine.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

Loïc Hoguin

More information about the erlang-questions mailing list