<div dir="ltr">Yuck, it behaves badly on Mac, but even worse on RPi. I get to maybe 30 shreds before it tanks... rs</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jun 23, 2014 at 5:33 PM, Michael Heuer <span dir="ltr">&lt;<a href="mailto:heuermh@gmail.com" target="_blank">heuermh@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Oops, forgot to increment count<br>
<br>
  &lt;&lt;&lt;&quot;count&quot;, count++&gt;&gt;&gt;;<br>
<br>
...<br>
<br>
$ chuck --silent examples/dmxBug.ck<br>
[chuck](VM): removing shred: 2 (spork~exp)...<br>
count 0<br>
[chuck](VM): removing shred: 3 (spork~exp)...<br>
count 1<br>
<div class="">...<br>
[chuck](VM): removing shred: 144 (spork~exp)...<br>
</div>count 142<br>
<div class="">[chuck](VM): removing shred: 145 (spork~exp)...<br>
</div>count 143<br>
<div class="im HOEnZb">[chuck](VM): removing shred: 146 (spork~exp)...<br>
Segmentation fault: 11<br>
<br>
<br>
</div><div class="HOEnZb"><div class="h5">On Mon, Jun 23, 2014 at 5:31 PM, Michael Heuer &lt;<a href="mailto:heuermh@gmail.com">heuermh@gmail.com</a>&gt; wrote:<br>
&gt; Interesting find, even this simple example blows for me<br>
&gt;<br>
&gt; dmxBug.ck:<br>
&gt;<br>
&gt; fun void blink()<br>
&gt; {<br>
&gt;   while (true)<br>
&gt;   {<br>
&gt;     50::ms =&gt; now;<br>
&gt;   }<br>
&gt; }<br>
&gt;<br>
&gt; Shred shred;<br>
&gt; spork ~ blink() @=&gt; shred;<br>
&gt;<br>
&gt; 0 =&gt; int count;<br>
&gt;<br>
&gt; while (true)<br>
&gt; {<br>
&gt;   200::ms =&gt; now;<br>
&gt;   <a href="http://shred.id" target="_blank">shred.id</a>() =&gt; Machine.remove;<br>
&gt;   spork ~ blink() @=&gt; shred;<br>
&gt;   &lt;&lt;&lt;&quot;count&quot;, count&gt;&gt;&gt;;<br>
&gt; }<br>
&gt;<br>
&gt; $ chuck --silent examples/dmxBug.ck<br>
&gt; ...<br>
&gt; [chuck](VM): removing shred: 144 (spork~exp)...<br>
&gt; count 0<br>
&gt; [chuck](VM): removing shred: 145 (spork~exp)...<br>
&gt; count 0<br>
&gt; [chuck](VM): removing shred: 146 (spork~exp)...<br>
&gt; Segmentation fault: 11<br>
&gt;<br>
&gt;    michael<br>
&gt;<br>
&gt;<br>
&gt; On Mon, Jun 23, 2014 at 5:17 PM, Ryan Supak &lt;<a href="mailto:ryansupak@gmail.com">ryansupak@gmail.com</a>&gt; wrote:<br>
&gt;&gt; Update: I eliminated everything I could from the Shreds that were being<br>
&gt;&gt; Sporked, and I still get the exact same error (at exactly 147 Shreds.)<br>
&gt;&gt;<br>
&gt;&gt; Here is what I shortened the Shreds to:<br>
&gt;&gt;<br>
&gt;&gt; fun void Blink()<br>
&gt;&gt; {<br>
&gt;&gt;     while( true )<br>
&gt;&gt;     {<br>
&gt;&gt;         50::ms =&gt; now;<br>
&gt;&gt;     }<br>
&gt;&gt; }<br>
&gt;&gt;<br>
&gt;&gt; fun void LFOMod()<br>
&gt;&gt; {<br>
&gt;&gt;     while( true )<br>
&gt;&gt;     {<br>
&gt;&gt;         50::ms =&gt; now;<br>
&gt;&gt;     }<br>
&gt;&gt; }<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On Mon, Jun 23, 2014 at 4:22 PM, Ryan Supak &lt;<a href="mailto:ryansupak@gmail.com">ryansupak@gmail.com</a>&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Thanks for the thorough reply. I&#39;m doing one safer, even than &quot;voice<br>
&gt;&gt;&gt; stealing&quot;: each Spork is, at most, reconfiguring a single global oscillator.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Attached is the entire source. Lines 128-142 contain initialization code<br>
&gt;&gt;&gt; that creates a Shred to make an LED blink by sending a MIDI message within a<br>
&gt;&gt;&gt; time loop, and another Shred that sets the frequency of an LFO, polls it<br>
&gt;&gt;&gt; every ten milliseconds, and sends some Serial output based on the LFO<br>
&gt;&gt;&gt; position.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Anytime that the parameters controlling the blinking rate and the LFO<br>
&gt;&gt;&gt; rate/phase have occasion to change (when MIDI events come in to change<br>
&gt;&gt;&gt; them), the &quot;old&quot; Shreds are Machine.Remove&#39;d and they&#39;re recreated<br>
&gt;&gt;&gt; immediately following. You can see this at lines 343 and 589.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Notice that the LFOMod function and the Blink function aren&#39;t creating<br>
&gt;&gt;&gt; anything new (with the exception of local arguments being instantiated), but<br>
&gt;&gt;&gt; if you think those local arguments could be causing my problem I&#39;ll<br>
&gt;&gt;&gt; eliminate them too.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Please see the attached.<br>
&gt;&gt;&gt; rs<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On Mon, Jun 23, 2014 at 11:59 AM, Perry R Cook &lt;<a href="mailto:prc@cs.princeton.edu">prc@cs.princeton.edu</a>&gt;<br>
&gt;&gt;&gt; wrote:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; I have lots of programs that spork hundreds or thousands<br>
&gt;&gt;&gt;&gt; of shreds without this error.  So, without seeing your<br>
&gt;&gt;&gt;&gt; code, my guesses (and questions) are as follows:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Are you running this on a small memory architecture? Since<br>
&gt;&gt;&gt;&gt; you say headless, I&#39;m guessing maybe Raspberry Pi?  It<br>
&gt;&gt;&gt;&gt; could be that you&#39;re running out of memory, so see next<br>
&gt;&gt;&gt;&gt; question.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Does the shred that you&#39;re sporking declare new UGs or<br>
&gt;&gt;&gt;&gt; require memory to be allocated (arrays, lots of string<br>
&gt;&gt;&gt;&gt; manipulation, etc.)?  In general, this is a bad idea if you<br>
&gt;&gt;&gt;&gt; can avoid it.  ChucK does no garbage collection, which<br>
&gt;&gt;&gt;&gt; means that you need to be cautious about declaring memory.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; So even a shred as simple as:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; fun void mySine()  {<br>
&gt;&gt;&gt;&gt;     SinOsc s =&gt; dac;<br>
&gt;&gt;&gt;&gt;     Math.random2f(100,1000) =&gt; s.freq;<br>
&gt;&gt;&gt;&gt;     second =&gt; now;<br>
&gt;&gt;&gt;&gt;     s =&lt; dac;<br>
&gt;&gt;&gt;&gt; }<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; will eat up memory, because even though the SinOsc<br>
&gt;&gt;&gt;&gt; is unchucked and never computes again, the memory<br>
&gt;&gt;&gt;&gt; for that structure is still around.  We want, someday<br>
&gt;&gt;&gt;&gt; to make ChucK a proper garbage collecting language,<br>
&gt;&gt;&gt;&gt; but it&#39;s hard, especially for real-time systems.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; If this turns out to be your issue, then one way to<br>
&gt;&gt;&gt;&gt; handle this is to make a global pool of fixed<br>
&gt;&gt;&gt;&gt; resources and have your shred grab from that.<br>
&gt;&gt;&gt;&gt; Like classic &quot;round robin voice stealing&quot; in<br>
&gt;&gt;&gt;&gt; synthesizers:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; SinOsc s[100];<br>
&gt;&gt;&gt;&gt; 0 =&gt; int next2Use;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; fun void mySine() {<br>
&gt;&gt;&gt;&gt;     next2Use =&gt; int thisOne;<br>
&gt;&gt;&gt;&gt;     1 +=&gt; next2Use;<br>
&gt;&gt;&gt;&gt;     if (next2Use &gt; 99) 0 =&gt; next2Use;<br>
&gt;&gt;&gt;&gt;     s[thisOne] =&gt; dac;<br>
&gt;&gt;&gt;&gt;     Math.random2f(100,1000) =&gt; s[thisOne].freq;<br>
&gt;&gt;&gt;&gt;     second =&gt; now;<br>
&gt;&gt;&gt;&gt;     s[thisOne] =&lt; dac;<br>
&gt;&gt;&gt;&gt; }<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; // to test:<br>
&gt;&gt;&gt;&gt; while (1) {<br>
&gt;&gt;&gt;&gt;     Math.random2f(0.01,0.1) :: second =&gt; now;<br>
&gt;&gt;&gt;&gt;     spork ~ mySine();<br>
&gt;&gt;&gt;&gt; }<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; I just fired up a few dozen of these running in<br>
&gt;&gt;&gt;&gt; parallel, VM showed 2600 total shreds running,<br>
&gt;&gt;&gt;&gt; no problem (and no clicks or dropouts!!).<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Hope this helps, if none of this applies, then you<br>
&gt;&gt;&gt;&gt; may have discovered a strange bug.  Source code please,<br>
&gt;&gt;&gt;&gt; and we can all scratch our heads on it.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;  Thanx!!  PRC<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Today&#39;s Topics:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;    1. 147th shred removed...segmentation fault? (Ryan Supak)<br>
&gt;&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt;&gt; chuck-users mailing list<br>
&gt;&gt;&gt;&gt; <a href="mailto:chuck-users@lists.cs.princeton.edu">chuck-users@lists.cs.princeton.edu</a><br>
&gt;&gt;&gt;&gt; <a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; chuck-users mailing list<br>
&gt;&gt; <a href="mailto:chuck-users@lists.cs.princeton.edu">chuck-users@lists.cs.princeton.edu</a><br>
&gt;&gt; <a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br>
&gt;&gt;<br>
_______________________________________________<br>
chuck-users mailing list<br>
<a href="mailto:chuck-users@lists.cs.princeton.edu">chuck-users@lists.cs.princeton.edu</a><br>
<a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br>
</div></div></blockquote></div><br></div>