Discussion:
[omniORB] omni_thread join problem - leads to core dump
Christoph Becker
2010-06-09 02:38:23 UTC
Permalink
Hi,

I don't know if I'm right or not, but omni thread IMHO is more or less
a part of omniorb.
So I have the problem that a join() always results in a core dump
after throwing an omni_thread_invalid.

...
MyT* t = new MyT;
t->start();

/* won't work
* -> terminate called after throwing an instance of 'omni_thread_invalid'
*/
int * rv;
t->join((void**) &rv); // <- breaks here

The complete minimal resides @ http://tinypaste.com/55592

Any help is welcome.

Cheers,
Christoph
Bruce Visscher
2010-06-09 02:56:42 UTC
Permalink
Christoph,

This is pretty easy.

??? void start(void);
??? // start() causes a thread created with one of the constructors to
??? // start executing the appropriate function.
...
??? void start_undetached(void);
??? // can be used with the above constructor in a derived class to cause
??? // the thread to be undetached.? In this case the thread executes the
??? // run_undetached member function.
...
??? void join(void**);
??? // join causes the calling thread to wait for another's completion,
??? // putting the return value in the variable of type void* whose address
??? // is given (unless passed a null pointer). Only undetached threads
??? // may be joined. Storage for the thread will be reclaimed.

so, you tried to join a detached thread. You can't do that. What you
basically do with a detached thread is somehow "signal" it to shut down
then trust that it will.

(Having said that, I really dislike the word "undetached". I would have
preferred that they used "detached" vs "managed" or something like that.
Of course, maybe the terminology came from the POSIX standard...)

HTH,
Bruce

On Tue, Jun 8, 2010 at 4:37 PM, Christoph Becker
Post by Christoph Becker
Hi,
I don't know if I'm right or not, but omni thread IMHO is more or less
a part of omniorb.
So I have the problem that a join() always results in a core dump
after throwing an omni_thread_invalid.
...
MyT* t = new MyT;
t->start();
/* won't work
?* -> terminate called after throwing an instance of 'omni_thread_invalid'
?*/
int * rv;
t->join((void**) &rv); // <- breaks here
Any help is welcome.
Cheers,
?Christoph
_______________________________________________
omniORB-list mailing list
http://www.omniorb-support.com/mailman/listinfo/omniorb-list
Bruce Visscher
2010-06-09 03:32:36 UTC
Permalink
Forgot to mention ownership. Never delete a detached thread. The
omni_thread class takes care of this for you. Always delete a managed
thread (after joining of course). If you think about it, this is the
only design that makes sense.

I usually prefer detached threads.
Post by Bruce Visscher
Christoph,
This is pretty easy.
??? void start(void);
??? // start() causes a thread created with one of the constructors to
??? // start executing the appropriate function.
...
??? void start_undetached(void);
??? // can be used with the above constructor in a derived class to cause
??? // the thread to be undetached.? In this case the thread executes the
??? // run_undetached member function.
...
??? void join(void**);
??? // join causes the calling thread to wait for another's completion,
??? // putting the return value in the variable of type void* whose address
??? // is given (unless passed a null pointer). Only undetached threads
??? // may be joined. Storage for the thread will be reclaimed.
so, you tried to join a detached thread. ?You can't do that. What you
basically do with a detached thread is somehow "signal" it to shut down
then trust that it will.
(Having said that, I really dislike the word "undetached". ?I would have
preferred that they used "detached" vs "managed" or something like that.
Of course, maybe the terminology came from the POSIX standard...)
HTH,
Bruce
On Tue, Jun 8, 2010 at 4:37 PM, Christoph Becker
Post by Christoph Becker
Hi,
I don't know if I'm right or not, but omni thread IMHO is more or less
a part of omniorb.
So I have the problem that a join() always results in a core dump
after throwing an omni_thread_invalid.
...
MyT* t = new MyT;
t->start();
/* won't work
?* -> terminate called after throwing an instance of 'omni_thread_invalid'
?*/
int * rv;
t->join((void**) &rv); // <- breaks here
Any help is welcome.
Cheers,
?Christoph
_______________________________________________
omniORB-list mailing list
http://www.omniorb-support.com/mailman/listinfo/omniorb-list
Loading...