www.delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
X-SWARE-Spam-Status: | No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_93,SPF_PASS |
X-Spam-Check-By: | sourceware.org |
Message-ID: | <4A687264.4080206@gmail.com> |
Date: | Thu, 23 Jul 2009 15:23:32 +0100 |
From: | Dave Korn <dave DOT korn DOT cygwin AT googlemail DOT com> |
User-Agent: | Thunderbird 2.0.0.17 (Windows/20080914) |
MIME-Version: | 1.0 |
To: | cygwin AT cygwin DOT com |
Subject: | Re: strange behavior with threads... |
References: | <1de9d39c0907230650t3ae02e2agc540e9ef8fe4ca34 AT mail DOT gmail DOT com> |
In-Reply-To: | <1de9d39c0907230650t3ae02e2agc540e9ef8fe4ca34@mail.gmail.com> |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
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
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |