| www.delorie.com/archives/browse.cgi | search |
| X-Recipient: | archive-cygwin AT delorie DOT com |
| X-Spam-Check-By: | sourceware.org |
| Date: | Thu, 23 Jul 2009 16:11:37 +0200 |
| From: | Corinna Vinschen <corinna-cygwin AT cygwin DOT com> |
| To: | cygwin AT cygwin DOT com |
| Subject: | Re: strange behavior with threads... |
| Message-ID: | <20090723141137.GA18621@calimero.vinschen.de> |
| Reply-To: | cygwin AT cygwin DOT com |
| Mail-Followup-To: | cygwin AT cygwin DOT com |
| References: | <1de9d39c0907230650t3ae02e2agc540e9ef8fe4ca34 AT mail DOT gmail DOT com> |
| MIME-Version: | 1.0 |
| In-Reply-To: | <1de9d39c0907230650t3ae02e2agc540e9ef8fe4ca34@mail.gmail.com> |
| User-Agent: | Mutt/1.5.19 (2009-02-20) |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Id: | <cygwin.cygwin.com> |
| List-Unsubscribe: | <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT 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 |
On Jul 23 15:50, jean-luc malet wrote:
> Hi!
> I've the following code :
> void _Window::Start(void* arg)
> {
> ThreadArgs args;
> args.TheWindow=this;
> args.args=arg;
> int err = pthread_create(&main_thread,NULL,_Start, (void*)&args);
> if (err)
> {
> throw new Exception(err, "window thread creation error");
> }
> }
> void* _Window::_Start(void* arg)
> {
> ThreadArgs* args = (ThreadArgs*) arg;
> pthread_exit((void*)args->TheWindow->start_routine(args->args));
> }
>
> _Window::_Start is static
>
> for some reason that I can't determine it happens that args in
> _Window::_Start have strange value (args->TheWindow don't contain a
> valid pointer, ie a pointer on a _Window object)
Maybe you shouldn't let the arg to the thread point to a local
stack-based variable in the other method which, as you code implies,
returns after having started the thread...
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Project Co-Leader cygwin AT cygwin DOT com
Red Hat
--
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 |