This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

strange behavior with threads...


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

-- 
KISS! (Keep It Simple, Stupid!)
(garde le simple, imbÃcile!)
"mais qu'est-ce que tu m'as pondu comme usine à gaz? fait des choses
simples et qui marchent, espÃce d'imbÃcile!"
-----------------------------
"Si vous pensez que vous Ãtes 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]