On Thu, 2005-01-06 at 18:17 +0200, David Harel wrote: > Hi, > > I hope you can help me. I was looking for the right answer everywhere on > the net. > > When I do pthread_exit(retval); and I do pthread_join(&retval); at the > "calling" thread... [snip] > Still, retval is a pointer, i guess to somewhere in the terminated > thread space (stack frame) but after pthread_join() the terminated > thread space can be reclaimed. What if another thread reclaims that > space and reuse it. Does that mean that retval will be invalid? and if > so. That's exactly your problem. You return a pointer (&taskid) to an area you don't own anymore... So in the best case, you'll get garbage, and when not assigned to one of your threads, it will SEGV.
> How can I save retval safely? To solve this you can (based on your example): 1) return taskid instead of it's pointer (&taskid), or 2) if you have to return a significant amount of memory, then have it alloc'ed. Hope this helps, -- ____________________________ ________ _______________________________ | Pablo 'merKur' Kohan \ \ / | | Founder, CTO \ \/ To bring IN-OVATION turn to | | mailto:[EMAIL PROTECTED] /\ \ your open source of solutions | | Phone: +972-544-225371 / \ \ | | Fax: +972-151-544-225371 -------- http://www.ximpo.com/ | |__________________________ Ximpo Group _____________________________| ================================================================= To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]