<div dir="ltr"><div>Well, that's not the dsp function. Paul-Arthur is right, it seems that the crash occurs during the change of the pd instance. I didn't find a way to secure the function calls but I'm not at all an expert about threads. Perhaps, one solution would be to have thread-safe functions like this : </div>
<div>void dsp_tick(t_pdinstance *x)</div><div>{</div><div>    if (x->pd_dspchain)</div><div>    {</div><div>        t_int *ip;</div><div>        for (ip = x->pd_dspchain; ip; )</div><div>            ip = (*(t_perfroutine)(*ip))(ip);</div>
<div>    }</div><div>}</div><div>Thus, you can touch a instance while another computes its dsp chain. I think we can have something like this without changing the core of pd if the functions have other names but it's still complicated to implement. In this case, another point would be to change the dsp methods of the dac~ and the adc~ because if we want to call the functions in parallel, they should use io vectors specific to the instance. Am I going too far ?</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-07-13 11:36 GMT+02:00 Pierre Guillot <span dir="ltr"><<a href="mailto:guillotpierre6@gmail.com" target="_blank">guillotpierre6@gmail.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi,</div><div>I'm also working on it and I have similar issues. Perhaps, the crash comes from "canvas_stop_dsp()". It seems like when you open a patch, the function is called and frees some unallocated memory. I have to investigate a little bit more, there is always a solution but if you find it before, I'll be pleased to know it. My project is in the plugin folder of this repository : <a href="https://github.com/CICM/CreamLibrary" target="_blank">https://github.com/CICM/CreamLibrary</a>.</div>

<div><br></div><div>Cheers,</div><div>Pierre</div>







</div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-07-12 11:51 GMT+02:00 Miller Puckette via Pd-dev <span dir="ltr"><<a href="mailto:pd-dev@lists.iem.at" target="_blank">pd-dev@lists.iem.at</a>></span>:<div>
<div class="h5"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Sorry - I hadn't run into lbpd_lock() but that's almost certainly the<br>
think I thought you'd need :)  But now I don't know why it's crashing..<br>
<div><div><br>
M<br>
<br>
><br>
> I don't understand what you mean by protect libpd calls with a lock. Isn't<br>
> it what I'm doing with libpd_lock() ?<br>
><br>
><br>
> 2014-07-08 12:39 GMT+02:00 Miller Puckette <<a href="mailto:msp@ucsd.edu" target="_blank">msp@ucsd.edu</a>>:<br>
><br>
> > On minor thing - you probably have to protect all of the libpd() calls with<br>
> > a lock to keep separate threads from getting to it simultaneously.  (It's<br>
> > not sufficient to just use the "THREAD_LOCK" mechanism in Pd - that would<br>
> > protect Pd OK but not the libpd code.<br>
> ><br>
> > cheers<br>
> > Miller<br>
> ><br>
> > On Tue, Jul 08, 2014 at 11:56:36AM +0200, Paul-Arthur Sauvageot via Pd-dev<br>
> > wrote:<br>
> > > ><br>
> > > > from your host? from juce?<br>
> > > > fgmsdr<br>
> > > > IOhannes<br>
> > ><br>
> > ><br>
> > > I tried with different hosts and the problem is the same.<br>
> > > I don't think it comes from JUCE neither. The things is if I remove the<br>
> > > pd_setinstance() calls, it doesn't crash (But the sound is ugly, as it<br>
> > was<br>
> > > before the multi instance update, which is logic). The weird thing being<br>
> > > that it doesn't crash in the VST functions, but it has something to do<br>
> > with<br>
> > > those pd_setinstance() calls which are only made on the VST functions...<br>
> > ><br>
> > ><br>
> > > 2014-07-08 11:43 GMT+02:00 IOhannes m zmoelnig <<a href="mailto:zmoelnig@iem.at" target="_blank">zmoelnig@iem.at</a>>:<br>
> > ><br>
> > > > -----BEGIN PGP SIGNED MESSAGE-----<br>
> > > > Hash: SHA256<br>
> > > ><br>
> > > > On 2014-07-08 10:54, Paul-Arthur Sauvageot via Pd-dev wrote:<br>
> > > > > Hello,<br>
> > > > ><br>
> > > > > I'm currently trying to make a VST that uses libpd and the pd<br>
> > > > > update allowing multi instances (via pd_instance). But it's not<br>
> > > > > working,<br>
> > > ><br>
> > > > i would be very surprised if - at this moment - the multi-instance<br>
> > > > code *would* be working.<br>
> > > > afaict, we are making *small* steps towards this goal.<br>
> > > ><br>
> > > ><br>
> > > > > According to my logs and my debugger, it never crashes in the VST<br>
> > > > > functions, it seems to crash on some pthread functions like<br>
> > > > > pthread_kill but I never use these functions...<br>
> > > > ><br>
> > > > > Does someone has any idea of where it could come from ?<br>
> > > ><br>
> > > > from your host? from juce?<br>
> > > ><br>
> > > > fgmsdr<br>
> > > > IOhannes<br>
> > > ><br>
> > > > -----BEGIN PGP SIGNATURE-----<br>
> > > > Version: GnuPG v1<br>
> > > > Comment: Using GnuPG with Icedove - <a href="http://www.enigmail.net/" target="_blank">http://www.enigmail.net/</a><br>
> > > ><br>
> > > > iQIcBAEBCAAGBQJTu70fAAoJELZQGcR/ejb4KdAP/iLrhMFWQ4ZSff8+AX1YnHo/<br>
> > > > DO7N/fgkh2AfUiJiqZfLQqZT7DQYIweyOBk0p+vtpFeNZR76D4xuNDOAiC0V5/Nf<br>
> > > > XWJq/nq40Rg5SL/Gej9fpI0/ahVTovTpnmZt4CgAfKqwb2GVWoqDUBjiZ/hIxffi<br>
> > > > hH1szv5AeXdDAJp67PxGk/b0zv9m+pi0tS0CB2j5Fh3RlTqTefV6ZKI0cZAv6jth<br>
> > > > +qQA9OJzEHK4bpNoCMQbtJqr8XbREhD/mG+1yLopnm5fvkUyravVTqqaPczZuqUq<br>
> > > > YJ7EH4z5FGjeRjDI5k0MRkdu093Iv7w/iWf0HNRQPL8AM4Hm4XdntYI8B1lkYVFg<br>
> > > > lmxqKjuV9JKaPLzY7ztlxqPxFO7oKy2BQe4Z73F8aBi8w79dGEx+p2CclzC8oLnX<br>
> > > > arIPCIlA9Ybaie4GCwbMi2REO4/XK/CxgP3YV97FdU3wjE83mBOPcx1RYAWY+XVV<br>
> > > > 0T3hioln+R95eaBr4EoO6X1vtxhw2IFhEju4AzGmhwQx3Wo3eFfH2Bkf6Crwkl+o<br>
> > > > 10tWXKfaUZS5lPbkAb04ardPvF8GAs/HXnZBeJGvXSf4TICc6OZILMNFM4yM2rcg<br>
> > > > uX2lPZqU3bOnrFpyIxR7J/UgV3DsMbfd7nTmUJaY0q6DGoYaiiwAzEyN2hTOGvYx<br>
> > > > iwiZ9lpCKTQZCpXtt679<br>
> > > > =R/3q<br>
> > > > -----END PGP SIGNATURE-----<br>
> > > ><br>
> > ><br>
> > ><br>
> > ><br>
> > > --<br>
> > > SAUVAGEOT Paul-Arthur.<br>
> > > Développeur C \ C++ \ C#.<br>
> ><br>
> > > _______________________________________________<br>
> > > Pd-dev mailing list<br>
> > > <a href="mailto:Pd-dev@lists.iem.at" target="_blank">Pd-dev@lists.iem.at</a><br>
> > > <a href="http://lists.puredata.info/listinfo/pd-dev" target="_blank">http://lists.puredata.info/listinfo/pd-dev</a><br>
> ><br>
> ><br>
><br>
><br>
> --<br>
> SAUVAGEOT Paul-Arthur.<br>
> Développeur C \ C++ \ C#.<br>
<br>
_______________________________________________<br>
Pd-dev mailing list<br>
<a href="mailto:Pd-dev@lists.iem.at" target="_blank">Pd-dev@lists.iem.at</a><br>
<a href="http://lists.puredata.info/listinfo/pd-dev" target="_blank">http://lists.puredata.info/listinfo/pd-dev</a><br>
</div></div></blockquote></div></div></div><br></div>
</blockquote></div><br></div>