[PD-dev] pd external memory weirdness

tim redfern pd at eclectronics.org
Thu Apr 17 13:35:53 CEST 2008


apologies, I figured out I needed to make the thread 'detached'.

thanks for your attention..

T


On Wed, 2008-04-16 at 19:25 +0100, Claude Heiland-Allen wrote:
> Hi Tim, list,
> 
> First, I never wrote anything with pthreads, so this may be way off the 
> mark, but this looks suspicious:
> 
> tim redfern wrote:
> > void thread_bang(t_thread *x)
> > {
> >         char* temp=(char*)malloc(1000000);
> >         free(temp);
> >         
> >         pthread_t stest;
> >         pthread_create (&stest,&gen_attr,threadtester,(void *) x);
> >         post("hello world!");
> > }
> 
> stest disappears when the thread_bang() returns, the thread is still 
> running, and maybe pthread internals write to stest after it is no 
> longer there, which would be very bad:  at best, a segmentation fault, 
> at worst, no crash but wrong behaviour.
> 
> At a guess: malloc() a list node with the pthread_t in it, and store 
> those nodes in a list in the Pd object struct.
> 
> 
> Claude





More information about the Pd-dev mailing list