Yup - builds fine, and it resolved the crash in my system as well.
Thanks for taking care of it!!
AC
On 9/24/07, Robert Osfield <[EMAIL PROTECTED]> wrote:
> Hi Adam,
>
> I have recreated the crash, and have applied a fix to
> OpenThreads::Thread to resolve it. The fix involved added a Mutex to
> Thread which is used to prevent the startThread and destructor running
> in parallel. This certainly resolves the crash under Linux for my
> tests. I have rolled exactly the same changes into the Win32 and
> Sproc code too as these will have exhibited exactly the same problem.
>
> Could you do a svn update and let me know how you get on.
>
> Cheers,
> Robert.
>
> On 9/20/07, Adam Coates <[EMAIL PROTECTED]> wrote:
> > I've attached the version I'm using that demonstrates the unusability
> > of the isRunning() flag.
> >
> > The code pasted into the last e-mail is all that's necessary to
> > illustrate the crash, though it doesn't try to avoid it using the
> > 'isRunning' flag. You shouldn't need to modify the OpenThreads
> > library.
> >
> > I get the following error after running the attached code:
> > "pure virtual method called
> > terminate called without an active exception
> > Aborted"
> >
> > presumably because thread->run() is being called on an object that has
> > been trashed.
> >
> > AC
> >
> > On 9/20/07, Robert Osfield <[EMAIL PROTECTED]> wrote:
> > > Hi Adam,
> > >
> > > Could you send the exact code that you can recreate the issue with.
> > >
> > > Robert.
> > >
> > > On 9/20/07, Adam Coates <[EMAIL PROTECTED]> wrote:
> > > > Ah - just double-checked. It'll crash just fine without adding the
> > > > usleep() to OpenThreads; I had my builds mixed up.
> > > >
> > > > AC
> > > >
> > > > On 9/20/07, Adam Coates <[EMAIL PROTECTED]> wrote:
> > > > > Hi, Robert,
> > > > >
> > > > > The following is sufficient (basically what you said):
> > > > >
> > > > > #include <OpenThreads/Thread>
> > > > >
> > > > > class MyThread : public OpenThreads::Thread {
> > > > > public:
> > > > > void run(void) { }
> > > > > };
> > > > >
> > > > > int main(int argc, char* argv[]) {
> > > > > {
> > > > > MyThread thread;
> > > > > thread.startThread();
> > > > > }
> > > > > while(1) ;
> > > > > return 0;
> > > > > }
> > > > >
> > > > > You need the while(1) ; to prevent the process from dying and cleaning
> > > > > up the thread before it wrecks. This alone wouldn't reproduce the bug
> > > > > because the interleaving doesn't happen (it's a very short window in
> > > > > which it can happen). To force the bug, I added ::usleep(1000000) at
> > > > > the beginning of ThreadPrivateActions::StartThread().
> > > > >
> > > > > AC
> > > > >
> > > > > On 9/20/07, Robert Osfield <[EMAIL PROTECTED]> wrote:
> > > > > > Hi Adam,
> > > > > >
> > > > > > On 9/20/07, Adam Coates <[EMAIL PROTECTED]> wrote:
> > > > > > > So, I just realized that the OSG folks are not synonymous with the
> > > > > > > OpenThreads folks. ^_^ Sorry for dropping this on the wrong list
> > > > > > > then.
> > > > > >
> > > > > > Well OpenThreads list is a flat line, almost all (99.9%)
> > > > > > OpenThreads
> > > > > > activity and development is done by members of the OpenSceneGraph
> > > > > > community. So this is probably the best place to raise issues like
> > > > > > this. Responsibility for maintaining OpenThreads has also fallen on
> > > > > > my shoulders as it effectively became an orphaned project when the
> > > > > > original project lead got sucked into non coding management.
> > > > > >
> > > > > > >In that light, it may not even be considered a bug in OT,
> > > > > > > since, theoretically, it might be unfair to call the Thread
> > > > > > > destructor
> > > > > > > while the thread is running (even though I'm pretty sure they
> > > > > > > intended
> > > > > > > isRunning() to work as we'd expect).
> > > > > >
> > > > > > Well this type of usage is kinda abusing the Thread class, but I'd
> > > > > > still say this way a bug.
> > > > > >
> > > > > > > It should be possible to add a workaround in the following way:
> > > > > > >
> > > > > > > 1. Before starting the thread, set a flag to indicate that the
> > > > > > > thread
> > > > > > > is "starting up".
> > > > > > > 2. Have the thread's run() routine unset this flag.
> > > > > > >
> > > > > > > Before deleting the Thread, make sure that both the "starting up"
> > > > > > > flag
> > > > > > > and the isRunning flag are false. One of these will have to be
> > > > > > > true
> > > > > > > if the thread has not reached the run() method yet, or has not
> > > > > > > completely exited from run() -- thus avoiding the problem.
> > > > > >
> > > > > > I'll have ponder in this issue, I'm more inclined to use a mutex in
> > > > > > some way that just a straight flag.
> > > > > >
> > > > > > > My question: does somebody want me to implement this workaround
> > > > > > > and
> > > > > > > submit it to you? Alternatively, I can just point out the break
> > > > > > > to
> > > > > > > the OpenThreads people and we can wait for a patch...
> > > > > >
> > > > > > It's best to just roll your sleeves up and get stuck in. First up
> > > > > > we
> > > > > > need a test that can reliably reproduce the error. Would the
> > > > > > following code block do the trick?
> > > > > >
> > > > > > {
> > > > > > OpenThreads::Thread thread;
> > > > > > thread.startThread();
> > > > > > }
> > > > > >
> > > > > > Robert.
> > > > > > _______________________________________________
> > > > > > osg-users mailing list
> > > > > > [email protected]
> > > > > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> > > > > >
> > > > >
> > > > _______________________________________________
> > > > osg-users mailing list
> > > > [email protected]
> > > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> > > >
> > > _______________________________________________
> > > osg-users mailing list
> > > [email protected]
> > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> > >
> >
> > _______________________________________________
> > osg-users mailing list
> > [email protected]
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> >
> >
> >
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org