X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-0.4 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_93,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org MIME-Version: 1.0 In-Reply-To: <20090723141137.GA18621@calimero.vinschen.de> References: <1de9d39c0907230650t3ae02e2agc540e9ef8fe4ca34 AT mail DOT gmail DOT com> <20090723141137 DOT GA18621 AT calimero DOT vinschen DOT de> Date: Fri, 24 Jul 2009 11:12:36 +0200 Message-ID: <1de9d39c0907240212w4d2809d2lc6904100f7a8c446@mail.gmail.com> Subject: Re: strange behavior with threads... From: jean-luc malet To: cygwin AT cygwin DOT com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , 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 Thu, Jul 23, 2009 at 4:11 PM, Corinna Vinschen wrote: > On Jul 23 15:50, jean-luc malet wrote: >> Hi! >> I've the following code : >> void _Window::Start(void* arg) >> { >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 ThreadArgs args; >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 args.TheWindow=3Dthis; >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 args.args=3Darg; >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 int err =3D pthread_create(&main_thread,NULL= ,_Start, (void*)&args); >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (err) >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 { >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 throw new =C2=A0= Exception(err, "window thread creation error"); >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 } >> } >> void* _Window::_Start(void* arg) >> { >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 ThreadArgs* args =3D (ThreadArgs*) arg; >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 pthread_exit((void*)args->TheWindow->start_r= outine(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 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0Please, send mails regarding Cygwin to > Cygwin Project Co-Leader =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0cygwin AT cygw= in DOT com > Red Hat > > -- > Problem reports: =C2=A0 =C2=A0 =C2=A0 http://cygwin.com/problems.html > FAQ: =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 http:= //cygwin.com/faq/ > Documentation: =C2=A0 =C2=A0 =C2=A0 =C2=A0 http://cygwin.com/docs.html > Unsubscribe info: =C2=A0 =C2=A0 =C2=A0http://cygwin.com/ml/#unsubscribe-s= imple > > Yes, sorry for such lame question :( I should have seen this issue the code has been modified and has been tested under linux and is now working as expected under linux, thanks however I have a X server connection issue freeglut (./tests/GENERATED/GlutWindowTest): Unable to create direct context rendering for window ' ' This may hurt performance. XIO: fatal IO error 11 (Resource temporarily unavailable) on X server ":0.= 0" after 34 requests (32 known processed) with 5 events remaining. think I will have to post on Cygwin/X ML thanks for help 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