delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/07/23/09:50:35

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=0.4 required=5.0 tests=AWL,BAYES_50,J_CHICKENPOX_93,SARE_MSGID_LONG40,SPF_PASS
X-Spam-Check-By: sourceware.org
MIME-Version: 1.0
Date: Thu, 23 Jul 2009 15:50:11 +0200
Message-ID: <1de9d39c0907230650t3ae02e2agc540e9ef8fe4ca34@mail.gmail.com>
Subject: strange behavior with threads...
From: jean-luc malet <jeanluc DOT malet AT gmail DOT com>
To: cygwin AT cygwin DOT com
X-IsSubscribed: yes
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

Hi!
I've the following code :
void _Window::Start(void* arg)
{
        ThreadArgs args;
        args.TheWindow=3Dthis;
        args.args=3Darg;
        int err =3D 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 =3D (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)
this happens on 2 thread configuration upon creation of the second
thread (1rst thread is main() and do only create the Window and sleep)
It happens randomly and backtrace on crash don't contain any usefull
information (looks exactly like the one when args->TheWindow is
correct)
I didn't tested on other posix system
thanks for your help
Regards
JLM

--=20
KISS! (Keep It Simple, Stupid!)
(garde le simple, imb=C3=A9cile!)
"mais qu'est-ce que tu m'as pondu comme usine =C3=A0 gaz? fait des choses
simples et qui marchent, esp=C3=A8ce d'imb=C3=A9cile!"
-----------------------------
"Si vous pensez que vous =C3=AAtes trop petit pour changer quoique ce soit,
essayez donc de dormir avec un moustique dans votre chambre." Betty
Reese
http://www.grainesdechangement.com/citations.htm

--
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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019