[PD-dev] pd external memory weirdness

Claude Heiland-Allen claudiusmaximus at goto10.org
Wed Apr 16 20:25:25 CEST 2008


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
-- 
http://claudiusmaximus.goto10.org




More information about the Pd-dev mailing list