<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Tip: Run on debug VM that adds a lot of runtime assertion<br>
for earlier bug detection and nicer core dump to inspect.<br>
For this case it will add an extra ref counter to every resource<br>
to detect unbalanced calls to enif_release_resource()<br>
that may otherwise go unnoticed and instead cause the GC to crash
later.<br>
<br>
$> (cd $ERL_TOP/erts/emulator && make TYPE=debug smp)<br>
$> $ERL_TOP/bin/cerl -debug<br>
<br>
<br>
/Sverker, Erlang/OTP<br>
<br>
<div class="moz-cite-prefix">On 08/08/2016 03:13 PM, Vincent
Siliakus wrote:<br>
</div>
<blockquote
cite="mid:CAKB6i_MuUcNEpSqEjQ7W9jXS5x5qWHjEKVPYD44a-CCzXfm3TQ@mail.gmail.com"
type="cite">
<pre wrap="">Thanks for the confirmation! In that case I think the issue I encountered
was that a resource was released before a keep call and thereby
unexpectedly deleted, but I'll investigate to be sure what was happening.
-vincent
On Sat, Aug 6, 2016 at 4:16 AM, Daniel Goertzen <a class="moz-txt-link-rfc2396E" href="mailto:daniel.goertzen@gmail.com"><daniel.goertzen@gmail.com></a>
wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Those functions have their own synchronization so no need to add your own.
The usage case you describe sound fine.
On Thu, Aug 4, 2016, 03:41 Vincent Siliakus <a class="moz-txt-link-rfc2396E" href="mailto:zambal@gmail.com"><zambal@gmail.com></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi,
Does anyone know if synchronization is needed when one calls
enif_keep_resource in nif functions and enif_release_resource in a nif
background thread? Or in other words: is the ref counting that is used
under the hood thread safe?
I ask this because during some refactoring of code in the LMDB driver I'm
developing at <a class="moz-txt-link-freetext" href="https://github.com/zambal/elmdb">https://github.com/zambal/elmdb</a> I stumbled upon a problem
that might have been caused by unsynchronized calls to these functions.
However, when I searched github for other code that uses resources , I
couldn't find examples that use synchronization, but that might be because
it's simply not needed in those libraries, so I'm still not sure.
Thanks,
Vincent
_______________________________________________
erlang-questions mailing list
<a class="moz-txt-link-abbreviated" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>
<a class="moz-txt-link-freetext" href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a>
</pre>
</blockquote>
<pre wrap="">
</pre>
</blockquote>
<pre wrap="">
</pre>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
erlang-questions mailing list
<a class="moz-txt-link-abbreviated" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>
<a class="moz-txt-link-freetext" href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a>
</pre>
</blockquote>
<br>
</body>
</html>