[erlang-questions] enif_send rules questions

Jason Orendorff jason.orendorff@REDACTED
Fri Jan 13 23:53:07 CET 2017

On Fri, Jan 13, 2017 at 10:09 AM, Sverker Eriksson <
sverker.eriksson@REDACTED> wrote:

> On 01/12/2017 08:21 PM, Jason Orendorff wrote:
>> 4.  We suspect it's actually totally safe to pass a process-independent
>>      environment as the first parameter, regardless of whether there's a
>>      "calling process" or we're "calling from a created thread". Is it?
>>      If so, would you accept a patch to document that that's OK?
> I'm not super excited about such a guarantee, at least not right now.

Thank you for the quick, thoughtful response. I appreciate your time.

Is there a way to enforce this rule for our users that we've missed? When
our `send` method is called, I think we have to figure out if there's a
calling process, and if so, its environment. I don't see a way to do it
storing that information in TLS ahead of time -- at a cost to every NIF

We could make code that runs on created threads statically different from
code that runs in the Erlang scheduler's threads, e.g. by making
`NifCallEnv`, `AllocatedEnvInNifThread`, and `AllocatedEnvInCreatedThread`
three different types, of which only 2 have `.send()` methods. But this
seems horrible.

We have considered several possible approaches, all about as bad as that.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170113/6c6fe6c6/attachment.htm>

More information about the erlang-questions mailing list