[PD-dev] Using PD funcs from inside a threaded external

Mathieu Bouchard matju at artengine.ca
Wed Mar 18 20:42:08 CET 2009


On Wed, 18 Mar 2009, B. Bogart wrote:

> The problem is that I've approached all the gphoto calling functions the
> same, but one particular function (listconfig) segfaults when I use PD
> functions, in particular outlet_symbol().
> I've attached the src.
> What is different about listconfig compared to say, getconfig, which
> works without a hitch?

You can't use Pd functions from another thread than the one that Pd runs 
in. Even banalities like gensym can fail.

Because those are race-condition issues, it will look like most 
things work, until something previously working mysteriously fails because 
of an obscure lucky timing that isn't lucky anymore. Very often, those 
crashes will appear to be random. They may also be "heisenbugs", which 
means that the bug seemingly disappears when you try to track it down, 
then reappears as soon as you try to run the programme normally...

You will need a special contraption to have the second thread talk to the 
first thread, involving a threadsafe queue of messages and something in 
the first thread that looks for messages in the queue. (argh.)

  _ _ __ ___ _____ ________ _____________ _____________________ ...
| Mathieu Bouchard - tél:+1.514.383.3801, Montréal, Québec


More information about the Pd-dev mailing list