Re: [osg-users] PagedLOD & DatabasePager crash

2010-01-22 Thread Robert Osfield
Hi Jason,

On Fri, Jan 22, 2010 at 6:40 PM, Jason Beverage  wrote:
> Just tested out your changes, the new methods get called and it seems to fix
> the crash, looks good to me.

Thanks for the feedback.  Changes now merged and submitted to svn/trunk.

Robert.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] PagedLOD & DatabasePager crash

2010-01-22 Thread Jason Beverage
Hi Robert,

Just tested out your changes, the new methods get called and it seems to fix
the crash, looks good to me.

Thanks!

Jason

On Fri, Jan 22, 2010 at 12:40 PM, Robert Osfield
wrote:

> Hi Jason,
>
> I've reviewed your change and while it will prevent this particular
> crash it will add an overhead that needn't be introduced.  I've made a
> provision change to DatabasePager::RequestQueue to add a destructor
> and a DatabaseRequest::valid() flag and a
> DatabaseRequest::invalidate() that the RequestQueue calls for all it's
> active DatabaseRequest that it owns.  This mechanism should invalidate
> the DatabaseRequests that are still attached to the scene graph and
> prevent them from being used later.
>
> Using the example I was unable to reproduce a crash, but I was able to
> get the new methods to invoke.  Could you please try the attached
> DatabasePager and DatabasePager.cpp.
>
> In your example it'd also be worth adding the following to prevent
> issues with missing textures on the second view.
>
>// disable the unref after apply as we'll be need to re-create the
> textures from images when the new graphics context
>// starts up.
>viewer1->getDatabasePager()->setUnrefImageDataAfterApplyPolicy(true,
> false);
>
> Could you (and others) let me know if my changes fix the crash you are
> seeing.  If it does I'll clean up the changes and get them checked
> into svn/trunk.
>
>
> Robert.
>
>
> On Thu, Jan 21, 2010 at 5:43 PM, Jason Beverage 
> wrote:
> > Hi all,
> >
> > I can confirm that this issue exists in 2.9.6 as well and believe Colin's
> > assessment is correct.  Changing the raw pointer to the RequestQueue in
> the
> > DatabaseRequest to an observer_ptr and taking a temporary ref when using
> it
> > fixes the issue.  I'm including a full program that you can use to test
> the
> > issue (based on Brett's program but using ref_ptr instead of raw pointers
> > for the Viewer ;) )
> >
> > I'll post a fix to osg-submissions shortly.
> >
> > Thanks!
> >
> > Jason
> >
> > #include 
> > #include 
> > #include 
> >
> > int main(int argc, char** argv)
> >  {
> >  std::string modelPath =
> > "http://www.openscenegraph.org/data/earth_bayarea/earth.ive";;
> >
> >  // create a scene graph (and keep it around).
> >  osg::ref_ptr modelNode = osgDB::readNodeFile(modelPath);
> >
> >  // create a viewer and set the scene graph data.
> >  osg::ref_ptr viewer = new osgViewer::Viewer();
> >  viewer->setSceneData(modelNode.get());
> >  viewer->setCameraManipulator(new osgGA::TrackballManipulator());
> >
> >  //Render the viewer until it's finished
> >  viewer->realize();
> >  while(!viewer->done())
> >  {
> >  viewer->frame();
> >  }
> >
> >  // Create  a new viewer and set the scene graph data to the same
> data.
> >  viewer = new osgViewer::Viewer();
> >  viewer->setCameraManipulator(new osgGA::TrackballManipulator());
> >  viewer->setSceneData(modelNode.get());
> >
> >  //Render until finished
> >  viewer->realize();
> >  while(!viewer->done())
> >  {
> >  viewer->frame();
> >  }
> >
> >  return 0;
> > }
> >
> > On Wed, Jan 20, 2010 at 3:40 PM, Robert Osfield <
> robert.osfi...@gmail.com>
> > wrote:
> >>
> >> Hi Brett,
> >>
> >> You really should learn to use ref_ptr<>'s, manually deleting ref
> >> counting objects is dangerous and only possible Viewer as I haven't
> >> put the destructor private to allow one to construct the Viewer on the
> >> stack for convenience, not to allow delete...
> >>
> >> That sermon aside, could you please try your example with svn/trunk or
> >> 2.9.6.
> >>
> >> Thanks,
> >> Robert.
> >>
> >>
> >>
> >> On Wed, Jan 20, 2010 at 8:25 PM, Brett Wiesner 
> >> wrote:
> >> > Robert,
> >> >
> >> > Here is a sample program that crashes when loading earth.ive the
> second
> >> > time. I'm using OSG 2.8.2.
> >> >
> >> > Thanks,
> >> > Brett
> >> >
> >> >  main()
> >> >  {
> >> >
> >> > std::string modelPath = "earth.ive";
> >> >
> >> > // create a scene graph (and keep it around).
> >> > osg::ref_ptr modelNode =
> osgDB::readNodeFile(modelPath);
> >> >
> >> > // create viewer1 and set the scene graph data.
> >> > osgViewer::Viewer* viewer1 = new osgViewer::Viewer;
> >> > viewer1->setUpViewOnSingleScreen(0);
> >> > viewer1->setSceneData(modelNode.get());
> >> > viewer1->setCameraManipulator(new osgGA::TrackballManipulator());
> >> >
> >> > // render a frame
> >> > viewer1->realize();
> >> > while(!viewer1->done())
> >> > {
> >> >viewer1->frame();
> >> > }
> >> >
> >> > // delete viewer1.
> >> > delete viewer1;
> >> > viewer1 = 0;
> >> >
> >> > // create viewer2 and set the scene graph data.
> >> >
> >> > osgViewer::Viewer* viewer2 = new osgViewer::Viewer;
> >> > viewer2->setUpViewOnSingleScreen(0);
> >> > viewer2->setSceneData(modelNode.get());
> >> > viewer2->setCameraManipulator(new osgGA::Tr

Re: [osg-users] PagedLOD & DatabasePager crash

2010-01-21 Thread Jason Beverage
Hi all,

I can confirm that this issue exists in 2.9.6 as well and believe Colin's
assessment is correct.  Changing the raw pointer to the RequestQueue in the
DatabaseRequest to an observer_ptr and taking a temporary ref when using it
fixes the issue.  I'm including a full program that you can use to test the
issue (based on Brett's program but using ref_ptr instead of raw pointers
for the Viewer ;) )

I'll post a fix to osg-submissions shortly.

Thanks!

Jason

#include 
#include 
#include 

int main(int argc, char** argv)
 {
 std::string modelPath = "
http://www.openscenegraph.org/data/earth_bayarea/earth.ive";;

 // create a scene graph (and keep it around).
 osg::ref_ptr modelNode = osgDB::readNodeFile(modelPath);

 // create a viewer and set the scene graph data.
 osg::ref_ptr viewer = new osgViewer::Viewer();
 viewer->setSceneData(modelNode.get());
 viewer->setCameraManipulator(new osgGA::TrackballManipulator());

 //Render the viewer until it's finished
 viewer->realize();
 while(!viewer->done())
 {
 viewer->frame();
 }

 // Create  a new viewer and set the scene graph data to the same data.
 viewer = new osgViewer::Viewer();
 viewer->setCameraManipulator(new osgGA::TrackballManipulator());
 viewer->setSceneData(modelNode.get());

 //Render until finished
 viewer->realize();
 while(!viewer->done())
 {
 viewer->frame();
 }

 return 0;
}

On Wed, Jan 20, 2010 at 3:40 PM, Robert Osfield wrote:

> Hi Brett,
>
> You really should learn to use ref_ptr<>'s, manually deleting ref
> counting objects is dangerous and only possible Viewer as I haven't
> put the destructor private to allow one to construct the Viewer on the
> stack for convenience, not to allow delete...
>
> That sermon aside, could you please try your example with svn/trunk or
> 2.9.6.
>
> Thanks,
> Robert.
>
>
>
> On Wed, Jan 20, 2010 at 8:25 PM, Brett Wiesner 
> wrote:
> > Robert,
> >
> > Here is a sample program that crashes when loading earth.ive the second
> > time. I'm using OSG 2.8.2.
> >
> > Thanks,
> > Brett
> >
> >  main()
> >  {
> >
> > std::string modelPath = "earth.ive";
> >
> > // create a scene graph (and keep it around).
> > osg::ref_ptr modelNode = osgDB::readNodeFile(modelPath);
> >
> > // create viewer1 and set the scene graph data.
> > osgViewer::Viewer* viewer1 = new osgViewer::Viewer;
> > viewer1->setUpViewOnSingleScreen(0);
> > viewer1->setSceneData(modelNode.get());
> > viewer1->setCameraManipulator(new osgGA::TrackballManipulator());
> >
> > // render a frame
> > viewer1->realize();
> > while(!viewer1->done())
> > {
> >viewer1->frame();
> > }
> >
> > // delete viewer1.
> > delete viewer1;
> > viewer1 = 0;
> >
> > // create viewer2 and set the scene graph data.
> >
> > osgViewer::Viewer* viewer2 = new osgViewer::Viewer;
> > viewer2->setUpViewOnSingleScreen(0);
> > viewer2->setSceneData(modelNode.get());
> > viewer2->setCameraManipulator(new osgGA::TrackballManipulator());
> >
> > // render a frame
> > viewer2->realize();
> >
> > while(!viewer2->done())
> > {
> >viewer2->frame();
> > }
> >
> > // check that it has textures.
> >
> > // delete viewer2.
> > delete viewer2;
> > viewer2 = 0;
> >
> >  }
> >
> > Robert Osfield wrote:
> >>
> >> Hi Colin,
> >>
> >> You make no mention of which version of the OSG you are using.  The
> >> DatabasePager and manage of GL objects when destroying contexts has
> >> improved significantly over the past year so the problems you are
> >> seeing may well be already resolved.
> >>
> >> Robert.
> >>
> >> On Thu, Jan 14, 2010 at 5:00 PM, Colin Branch  wrote:
> >>
> >>>
> >>> Greetings,
> >>>
> >>> Here's my steps:
> >>> I'm creating a compositeViewer with one or more views.
> >>> I'm loading a paged database.
> >>> While the database is paging, I delete the compositeViewer (thus taking
> >>> the
> >>> context down with it as well as the database pager).
> >>> I then create a new compositeViewer and attempt to render the sane
> >>> database
> >>> (same nodes).
> >>> I'm getting a crash in the database pager, specifically it crash in the
> >>> requestNodeFile function due to crashing on accessing invalid memory.
> >>>
> >>> The problem seems to step from the PagedLOD having a ref_ptr to a
> >>> DatabasePager::DatabaseRequest.
> >>> The databaseRequest has a raw pointer to a RequestQueue.
> >>> The RequestQueue is invalid (as it is a referenced member of the
> original
> >>> database pager, and thus is already deleted, but the DB request stayed
> >>> alive).
> >>> There appears to be no way of clearing the databaseRequest which is
> >>> referenced in the PagedLOD node.
> >>>
> >>> This appears to be a problem with how OSG handles database paging,
> >>> probably
> >>> a bug. No obvious solution pops out, mainly due to the low level nature
> >>> of
> >>> the prob

Re: [osg-users] PagedLOD & DatabasePager crash

2010-01-20 Thread Robert Osfield
Hi Brett,

You really should learn to use ref_ptr<>'s, manually deleting ref
counting objects is dangerous and only possible Viewer as I haven't
put the destructor private to allow one to construct the Viewer on the
stack for convenience, not to allow delete...

That sermon aside, could you please try your example with svn/trunk or 2.9.6.

Thanks,
Robert.



On Wed, Jan 20, 2010 at 8:25 PM, Brett Wiesner  wrote:
> Robert,
>
> Here is a sample program that crashes when loading earth.ive the second
> time. I'm using OSG 2.8.2.
>
> Thanks,
> Brett
>
>  main()
>  {
>
>     std::string modelPath = "earth.ive";
>
>     // create a scene graph (and keep it around).
>     osg::ref_ptr modelNode = osgDB::readNodeFile(modelPath);
>
>     // create viewer1 and set the scene graph data.
>     osgViewer::Viewer* viewer1 = new osgViewer::Viewer;
>     viewer1->setUpViewOnSingleScreen(0);
>     viewer1->setSceneData(modelNode.get());
>     viewer1->setCameraManipulator(new osgGA::TrackballManipulator());
>
>     // render a frame
>     viewer1->realize();
>     while(!viewer1->done())
>     {
>        viewer1->frame();
>     }
>
>     // delete viewer1.
>     delete viewer1;
>     viewer1 = 0;
>
>     // create viewer2 and set the scene graph data.
>
>     osgViewer::Viewer* viewer2 = new osgViewer::Viewer;
>     viewer2->setUpViewOnSingleScreen(0);
>     viewer2->setSceneData(modelNode.get());
>     viewer2->setCameraManipulator(new osgGA::TrackballManipulator());
>
>     // render a frame
>     viewer2->realize();
>
>     while(!viewer2->done())
>     {
>        viewer2->frame();
>     }
>
>     // check that it has textures.
>
>     // delete viewer2.
>     delete viewer2;
>     viewer2 = 0;
>
>  }
>
> Robert Osfield wrote:
>>
>> Hi Colin,
>>
>> You make no mention of which version of the OSG you are using.  The
>> DatabasePager and manage of GL objects when destroying contexts has
>> improved significantly over the past year so the problems you are
>> seeing may well be already resolved.
>>
>> Robert.
>>
>> On Thu, Jan 14, 2010 at 5:00 PM, Colin Branch  wrote:
>>
>>>
>>> Greetings,
>>>
>>> Here's my steps:
>>> I'm creating a compositeViewer with one or more views.
>>> I'm loading a paged database.
>>> While the database is paging, I delete the compositeViewer (thus taking
>>> the
>>> context down with it as well as the database pager).
>>> I then create a new compositeViewer and attempt to render the sane
>>> database
>>> (same nodes).
>>> I'm getting a crash in the database pager, specifically it crash in the
>>> requestNodeFile function due to crashing on accessing invalid memory.
>>>
>>> The problem seems to step from the PagedLOD having a ref_ptr to a
>>> DatabasePager::DatabaseRequest.
>>> The databaseRequest has a raw pointer to a RequestQueue.
>>> The RequestQueue is invalid (as it is a referenced member of the original
>>> database pager, and thus is already deleted, but the DB request stayed
>>> alive).
>>> There appears to be no way of clearing the databaseRequest which is
>>> referenced in the PagedLOD node.
>>>
>>> This appears to be a problem with how OSG handles database paging,
>>> probably
>>> a bug. No obvious solution pops out, mainly due to the low level nature
>>> of
>>> the problem.
>>> This is an important issue since it affects one of our customers.
>>> I welcome any comments/suggestions/workarounds.
>>>
>>> Thank you and best regards,
>>> Colin Branch
>>>
>>> --
>>> Colin Branch
>>> VT MAK
>>> work: (617) 876-8085 Ext. 159
>>> email: cbra...@mak.com
>>>
>>> ___
>>> osg-users mailing list
>>> osg-users@lists.openscenegraph.org
>>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>>
>>>
>>
>> ___
>> osg-users mailing list
>> osg-users@lists.openscenegraph.org
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] PagedLOD & DatabasePager crash

2010-01-20 Thread Brett Wiesner

Robert,

Here is a sample program that crashes when loading earth.ive the second 
time. I'm using OSG 2.8.2.


Thanks,
Brett

  main()
  {

 std::string modelPath = "earth.ive";

 // create a scene graph (and keep it around).
 osg::ref_ptr modelNode = osgDB::readNodeFile(modelPath);

 // create viewer1 and set the scene graph data.
 osgViewer::Viewer* viewer1 = new osgViewer::Viewer;
 viewer1->setUpViewOnSingleScreen(0);
 viewer1->setSceneData(modelNode.get());
 viewer1->setCameraManipulator(new osgGA::TrackballManipulator());

 // render a frame
 viewer1->realize();
 while(!viewer1->done())
 {
viewer1->frame();
 }

 // delete viewer1.
 delete viewer1;
 viewer1 = 0;

 // create viewer2 and set the scene graph data.

 osgViewer::Viewer* viewer2 = new osgViewer::Viewer;
 viewer2->setUpViewOnSingleScreen(0);
 viewer2->setSceneData(modelNode.get());
 viewer2->setCameraManipulator(new osgGA::TrackballManipulator());

 // render a frame
 viewer2->realize();

 while(!viewer2->done())
 {
viewer2->frame();
 }

 // check that it has textures.

 // delete viewer2.
 delete viewer2;
 viewer2 = 0;

  }

Robert Osfield wrote:

Hi Colin,

You make no mention of which version of the OSG you are using.  The
DatabasePager and manage of GL objects when destroying contexts has
improved significantly over the past year so the problems you are
seeing may well be already resolved.

Robert.

On Thu, Jan 14, 2010 at 5:00 PM, Colin Branch  wrote:
  

Greetings,

Here's my steps:
I'm creating a compositeViewer with one or more views.
I'm loading a paged database.
While the database is paging, I delete the compositeViewer (thus taking the
context down with it as well as the database pager).
I then create a new compositeViewer and attempt to render the sane database
(same nodes).
I'm getting a crash in the database pager, specifically it crash in the
requestNodeFile function due to crashing on accessing invalid memory.

The problem seems to step from the PagedLOD having a ref_ptr to a
DatabasePager::DatabaseRequest.
The databaseRequest has a raw pointer to a RequestQueue.
The RequestQueue is invalid (as it is a referenced member of the original
database pager, and thus is already deleted, but the DB request stayed
alive).
There appears to be no way of clearing the databaseRequest which is
referenced in the PagedLOD node.

This appears to be a problem with how OSG handles database paging, probably
a bug. No obvious solution pops out, mainly due to the low level nature of
the problem.
This is an important issue since it affects one of our customers.
I welcome any comments/suggestions/workarounds.

Thank you and best regards,
Colin Branch

--
Colin Branch
VT MAK
work: (617) 876-8085 Ext. 159
email: cbra...@mak.com

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
  


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] PagedLOD & DatabasePager crash

2010-01-14 Thread Colin Branch

Robert,

I'm using 2.8.2 and I verified the problem exists in the trunk.

-Colin

On 1/14/2010 12:13 PM, Robert Osfield wrote:

Hi Colin,

You make no mention of which version of the OSG you are using.  The
DatabasePager and manage of GL objects when destroying contexts has
improved significantly over the past year so the problems you are
seeing may well be already resolved.

Robert.

On Thu, Jan 14, 2010 at 5:00 PM, Colin Branch  wrote:
   

Greetings,

Here's my steps:
I'm creating a compositeViewer with one or more views.
I'm loading a paged database.
While the database is paging, I delete the compositeViewer (thus taking the
context down with it as well as the database pager).
I then create a new compositeViewer and attempt to render the sane database
(same nodes).
I'm getting a crash in the database pager, specifically it crash in the
requestNodeFile function due to crashing on accessing invalid memory.

The problem seems to step from the PagedLOD having a ref_ptr to a
DatabasePager::DatabaseRequest.
The databaseRequest has a raw pointer to a RequestQueue.
The RequestQueue is invalid (as it is a referenced member of the original
database pager, and thus is already deleted, but the DB request stayed
alive).
There appears to be no way of clearing the databaseRequest which is
referenced in the PagedLOD node.

This appears to be a problem with how OSG handles database paging, probably
a bug. No obvious solution pops out, mainly due to the low level nature of
the problem.
This is an important issue since it affects one of our customers.
I welcome any comments/suggestions/workarounds.

Thank you and best regards,
Colin Branch

--
Colin Branch
VT MAK
work: (617) 876-8085 Ext. 159
email: cbra...@mak.com

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

 

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
   


--
Colin Branch
VT MAK
work: (617) 876-8085 Ext. 159
email: cbra...@mak.com

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] PagedLOD & DatabasePager crash

2010-01-14 Thread Robert Osfield
Hi Colin,

You make no mention of which version of the OSG you are using.  The
DatabasePager and manage of GL objects when destroying contexts has
improved significantly over the past year so the problems you are
seeing may well be already resolved.

Robert.

On Thu, Jan 14, 2010 at 5:00 PM, Colin Branch  wrote:
> Greetings,
>
> Here's my steps:
> I'm creating a compositeViewer with one or more views.
> I'm loading a paged database.
> While the database is paging, I delete the compositeViewer (thus taking the
> context down with it as well as the database pager).
> I then create a new compositeViewer and attempt to render the sane database
> (same nodes).
> I'm getting a crash in the database pager, specifically it crash in the
> requestNodeFile function due to crashing on accessing invalid memory.
>
> The problem seems to step from the PagedLOD having a ref_ptr to a
> DatabasePager::DatabaseRequest.
> The databaseRequest has a raw pointer to a RequestQueue.
> The RequestQueue is invalid (as it is a referenced member of the original
> database pager, and thus is already deleted, but the DB request stayed
> alive).
> There appears to be no way of clearing the databaseRequest which is
> referenced in the PagedLOD node.
>
> This appears to be a problem with how OSG handles database paging, probably
> a bug. No obvious solution pops out, mainly due to the low level nature of
> the problem.
> This is an important issue since it affects one of our customers.
> I welcome any comments/suggestions/workarounds.
>
> Thank you and best regards,
> Colin Branch
>
> --
> Colin Branch
> VT MAK
> work: (617) 876-8085 Ext. 159
> email: cbra...@mak.com
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] PagedLOD & DatabasePager crash

2010-01-14 Thread Colin Branch

Greetings,

Here's my steps:
I'm creating a compositeViewer with one or more views.
I'm loading a paged database.
While the database is paging, I delete the compositeViewer (thus taking 
the context down with it as well as the database pager).
I then create a new compositeViewer and attempt to render the sane 
database (same nodes).
I'm getting a crash in the database pager, specifically it crash in the 
requestNodeFile function due to crashing on accessing invalid memory.


The problem seems to step from the PagedLOD having a ref_ptr to a 
DatabasePager::DatabaseRequest.

The databaseRequest has a raw pointer to a RequestQueue.
The RequestQueue is invalid (as it is a referenced member of the 
original database pager, and thus is already deleted, but the DB request 
stayed alive).
There appears to be no way of clearing the databaseRequest which is 
referenced in the PagedLOD node.


This appears to be a problem with how OSG handles database paging, 
probably a bug. No obvious solution pops out, mainly due to the low 
level nature of the problem.

This is an important issue since it affects one of our customers.
I welcome any comments/suggestions/workarounds.

Thank you and best regards,
Colin Branch

--
Colin Branch
VT MAK
work: (617) 876-8085 Ext. 159
email: cbra...@mak.com

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org