[PD-dev] How to pass indeterminate args to a thread
Martin Peach
martin.peach at sympatico.ca
Fri Feb 27 22:46:39 CET 2009
B. Bogart wrote:
>
> I'm now getting a segfault when trying to access a member of the
> structure in the thread function:
>
> #0 0xf7d531cb in strlen () from /lib/i686/cmov/libc.so.6
> #1 0xf7d1f648 in vfprintf () from /lib/i686/cmov/libc.so.6
> #2 0xf7d43e04 in vsnprintf () from /lib/i686/cmov/libc.so.6
> #3 0x080c68d6 in post (fmt=0xf7f7db5a "My symbol: %s")
> at s_print.c:51
> #4 0xf7f7d829 in mythread ()
> from /home/bbogart/src/gphoto/src/pd-external/gphoto2.pd_linux
>
> The way I'm trying to access the member is as follows:
>
> post("My symbol: %s", ((struct floatArgStruct *)threadArgs)->s->s_name);
>
You called pthread_create() with &threadargs:
ret = pthread_create( &thread1, NULL, mythread, &threadArgs);
when you probably should just use threadargs, since it's already a pointer.
Or else you need to dereference the handle:
post("My symbol: %s",
((*(struct floatArgStruct**))threadArgs)->s->s_name);
Martin
More information about the Pd-dev
mailing list