<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">Sorry, based on the Erlang shell it
seems to be running with SMP enabled, so that shouldn't be it.<br>
<br>
On 10/31/2014 07:27 PM, Michael Truog wrote:<br>
</div>
<blockquote cite="mid:545444FF.300@gmail.com" type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<div class="moz-cite-prefix">If "erl -smp disable" is being used I
assume it is the problem at <a moz-do-not-send="true"
class="moz-txt-link-freetext"
href="https://github.com/erlang/otp/pull/518">https://github.com/erlang/otp/pull/518</a><br>
<br>
On 10/31/2014 06:57 PM, Daniel Goertzen wrote:<br>
</div>
<blockquote
cite="mid:CAJCf5Ry4LQe0AW1ZsDLa_nPSAvwtg8B3fUeWYvMkS+qjBCJNjw@mail.gmail.com"
type="cite">
<div dir="ltr">Thanks for trying it out. That gist was a bit of
a hash; apologies.
<div><br>
</div>
<div>I made all the functions static and also put load and
unload as NULL in ERL_NIF_INIT, but I get the same results.
<div><br>
</div>
<div>I ran it under valgrind and got...</div>
<div><br>
</div>
<div><br>
</div>
<div><font face="courier new, monospace"># ERL_LIBS=..
valgrind --trace-children=yes erl<br>
</font></div>
<div><font face="courier new, monospace"><br>
</font></div>
<div><font face="courier new, monospace">...</font></div>
<div><font face="courier new, monospace"><br>
</font></div>
<div><span
id="docs-internal-guid-59ed9054-6908-5351-14ae-10195e0e3de0">
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">Eshell V6.2 (abort
with ^G)</font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">1> </font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">1>
dlibusb:mytest_io().</font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029== Thread 18:</font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029== Invalid
read of size 4</font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029== at
0x8190B56: process_main (beam_hot.h:935)</font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029== by
0x80E565E: sched_thread_func (erl_process.c:7719)</font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029== by
0x820982B: thr_wrapper (ethread.c:106)</font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029== by
0x40FFF46: start_thread (in /lib/<a
moz-do-not-send="true"
href="http://libpthread-2.20.so">libpthread-2.20.so</a>)</font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029== by
0x41FE97D: clone (in /lib/<a
moz-do-not-send="true"
href="http://libc-2.20.so">libc-2.20.so</a>)</font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029== Address
0xfffffffe is not stack'd, malloc'd or (recently)
free'd</font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029== </font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029== </font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029== Process
terminating with default action of signal 11
(SIGSEGV)</font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029== Access not
within mapped region at address 0xFFFFFFFE</font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029== at
0x8190B56: process_main (beam_hot.h:935)</font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029== by
0x80E565E: sched_thread_func (erl_process.c:7719)</font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029== by
0x820982B: thr_wrapper (ethread.c:106)</font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029== by
0x40FFF46: start_thread (in /lib/<a
moz-do-not-send="true"
href="http://libpthread-2.20.so">libpthread-2.20.so</a>)</font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029== by
0x41FE97D: clone (in /lib/<a
moz-do-not-send="true"
href="http://libc-2.20.so">libc-2.20.so</a>)</font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029== If you
believe this happened as a result of a stack</font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029== overflow
in your program's main thread (unlikely but</font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029== possible),
you can try to increase the size of the</font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029== main
thread stack using the --main-stacksize= flag.</font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029== The main
thread stack size used in this run was 8388608.</font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029== </font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029== HEAP
SUMMARY:</font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029== in use
at exit: 9,020,474 bytes in 157 blocks</font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029== total
heap usage: 211 allocs, 54 frees, 9,490,700 bytes
allocated</font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029== </font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029== LEAK
SUMMARY:</font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029==
definitely lost: 0 bytes in 0 blocks</font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029==
indirectly lost: 0 bytes in 0 blocks</font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029==
possibly lost: 14,143 bytes in 41 blocks</font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029== still
reachable: 9,006,331 bytes in 116 blocks</font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029==
suppressed: 0 bytes in 0 blocks</font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029== Rerun with
--leak-check=full to see details of leaked memory</font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029== </font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029== For counts
of detected and suppressed errors, rerun with: -v</font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">==9029== ERROR
SUMMARY: 1 errors from 1 contexts (suppressed: 0
from 0)</font></span></p>
<p dir="ltr"
style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span
style="color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
face="courier new, monospace">Killed</font></span></p>
<div><span
style="font-size:15px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><br>
</span></div>
<div><span
style="font-size:15px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><br>
</span></div>
<div><span
style="font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">Line
935 of my beam_hot.h is...</span></div>
<div><span
style="font-size:15px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><br>
</span></div>
<div><span
style="vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><font
style="font-size:15.4545450210571px"
color="#000000" face="Arial"> </font><font
color="#000000" face="courier new, monospace">OpCase(is_integer_fx):
{ BeamInstr* next; PreFetch(2, next);
IsInteger(xb(Arg(1)), ClauseFail()); // line 935
NextPF(2, next); }</font></span><span
style="font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">
</span></div>
<div><span
style="font-size:15px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><br>
</span></div>
<div><span
style="font-size:15px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><br>
</span></div>
<div><span
style="font-size:15px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">I
know little about beam internals. I don't know if
this is useful.</span></div>
<div><span
style="font-size:15px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><br>
</span></div>
</span></div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Fri, Oct 31, 2014 at 4:05 PM,
Steve Vinoski <span dir="ltr"><<a
moz-do-not-send="true" href="mailto:vinoski@ieee.org"
target="_blank">vinoski@ieee.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><br>
<div class="gmail_extra"><br>
<div class="gmail_quote"><span class="">On Fri, Oct
31, 2014 at 4:33 PM, Daniel Goertzen <span
dir="ltr"><<a moz-do-not-send="true"
href="mailto:daniel.goertzen@gmail.com"
target="_blank">daniel.goertzen@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote"
style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="ltr">I am seeing a segfault that
seems to be related to dirty schedulers.
I've reduced the fault to the erlang and C
nif module below which executes the same nif
with either the io dirty scheduler, the cpu
dirty scheduler, or the normal erlang
scheduler.
<div><br>
</div>
<div>
<div><br>
</div>
<div>When I start the emulator and run
either dirty nif, I get a segfault. (
see <a moz-do-not-send="true"
href="https://gist.github.com/goertzenator/6237e0200a5f7bf22976"
target="_blank">https://gist.github.com/goertzenator/6237e0200a5f7bf22976</a>)</div>
</div>
</div>
</blockquote>
<div><br>
</div>
</span>
<div>I found it hard to make sense of what's in
that gist due to the formatting, so I took your
code and built it myself. When I ran it, it
failed in your NIF load function, but it failed
in a way that didn't make sense because all your
function does is return 0. Then I realized none
of your C functions were declared static, which
means they are global, and I suspected your
load() function was clashing with some other
function of the same name. I made all your C
functions static, rebuilt, and then ran
everything and it seems like it worked:</div>
<div><br>
</div>
<div>> c(dlibusb).</div>
<div>Reading symbols for shared libraries . done</div>
<div>{ok,dlibusb}</div>
<div>2> dlibusb:mytest_cpu().<br>
</div>
<div>[ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,ok]</div>
<div>3> dlibusb:mytest_io().</div>
<div>[ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,ok]</div>
<div>4> dlibusb:mytest_none().</div>
<div>[ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,ok] </div>
<span class="HOEnZb"><font color="#888888">
<div><br>
</div>
<div>--steve</div>
</font></span></div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
erlang-questions mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a>
</pre>
</blockquote>
<br>
</blockquote>
<br>
</body>
</html>