<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 7 August 2018 at 11:23, Guilherme Andrade <span dir="ltr"><<a href="mailto:g@gandrade.net" target="_blank">g@gandrade.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>I've distilled the flow that triggers the crash and made a demo.<br><br> <a href="https://github.com/g-andrade/enif_send_crash" target="_blank">https://github.com/g-andrade/<wbr>enif_send_crash</a><br></div><div><br>It implements a dirty NIF which sends messages to a second process using enif_send() and a message containing a heap-allocated term. <br>It increases the number of iterations exponentially until it crashes.<br></div></div></blockquote><div><br></div><div>I've also created an issue[1] in the bug tracker after someone privately suggested it to me.<br><br>[1]: <a href="https://bugs.erlang.org/browse/ERL-695">https://bugs.erlang.org/browse/ERL-695</a><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div></div><div><br></div>This is what happens in my machine very consistently (macOS):<br><br>> ./enif_send_crash<br>> Trying to crash (1 iterations)...<br>> Trying to crash (2 iterations)...<br>> Trying to crash (4 iterations)...<br>> Trying to crash (8 iterations)...<br>> Trying to crash (16 iterations)...<br>> Trying to crash (32 iterations)...<br>> Trying to crash (64 iterations)...<br>> Trying to crash (128 iterations)...<br>> Trying to crash (256 iterations)...<br>> Trying to crash (512 iterations)...<br>> Trying to crash (1024 iterations)...<br><div>> beam/erl_nif.c:445:cache_env() Assertion failed: env->hp_end == (env->proc)->stop</div><div><br></div></div><div class="gmail_extra"><div><div class="gmail-h5"><br><div class="gmail_quote">On 7 August 2018 at 09:38, Guilherme Andrade <span dir="ltr"><<a href="mailto:g@gandrade.net" target="_blank">g@gandrade.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi,<br><div><div class="gmail_extra"><br><div class="gmail_quote"><span>On 20 June 2018 at 18:39, Sverker Eriksson <span dir="ltr"><<a href="mailto:sverker.eriksson@ericsson.com" target="_blank">sverker.eriksson@ericsson.com</a><wbr>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
I suggest you (and everybody during NIF development) to run on a debug-VM.<br>
It's slower but it catches a lot of faults earlier and produces a nicer core<br>
dump. It will catch enif_* API violations such as building tuples/lists/maps<br>
with terms from different environments.<br></blockquote><div><br></div></span><div>I finally found the time to look into this matter again. </div><div><br></div><div>Using a debug build of the VM (20.3), the crash consistently happens due to a failed assertion in line 445 of erl_nif.c[1].</div><div>Other conditions are the same as before.<br></div><div><br></div><div>Is this enlightening in anyway? I've got a 2.8 GiB core dump I can look into if you tell me that's the right direction to go.<br></div><div><br></div><div><br></div><div>[1]: <a href="https://github.com/erlang/otp/blob/OTP-20.3.8.4/erts/emulator/beam/erl_nif.c#L445" target="_blank">https://github.com/erlang/otp/<wbr>blob/OTP-20.3.8.4/erts/emulato<wbr>r/beam/erl_nif.c#L445</a><span class="gmail-m_-6791514192876193293HOEnZb"><font color="#888888"><br></font></span></div></div><span class="gmail-m_-6791514192876193293HOEnZb"><font color="#888888"><br>-- <br><div class="gmail-m_-6791514192876193293m_-6609681788290289888gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Guilherme<br></div></div></div></div></div></div>
</font></span></div></div></div>
</blockquote></div><br><br clear="all"><br></div></div><span class="gmail-HOEnZb"><font color="#888888">-- <br><div class="gmail-m_-6791514192876193293gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Guilherme<br></div></div></div></div></div></div>
</font></span></div>
</blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Guilherme<br></div></div></div></div></div></div>
</div></div>