This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: strange behavior with threads...
jean-luc malet wrote:
> Hi!
> I've the following code :
> void _Window::Start(void* arg)
> {
> ThreadArgs args;
This allocates a ThreadArgs struct on the stack.
> int err = pthread_create(&main_thread,NULL,_Start, (void*)&args);
This passes a pointer to the ThreadArgs struct on the stack to the new thread.
> if (err)
> {
> throw new Exception(err, "window thread creation error");
> }
> }
This then immediately exits and deallocates the stack frame, making the
&args pointer you passed to the main_thread invalid.
cheers,
DaveK
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple