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