OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

osgText crash with multiple Viewers


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
ravidavi
User


Joined: 06 Nov 2015
Posts: 57

PostPosted: Tue Dec 18, 2018 8:50 am    Post subject:
osgText crash with multiple Viewers
Reply with quote

Hello all,

I'm seeing a crash on the OpenSceneGraph-3.6 branch that occurs when I have two CompositeViewers that contain Text objects in their scenes. My simplified scenario is this:
- 2 CompositeViewers, each in singlethreaded mode, but being run at the same time in separate threads (via OpenThreads::Thread wrappers)
- The viewers do not share scenes or contexts, and each has a single Text object as its scene
- Each viewer is destroyed immediately after its run() loop returns (needed for my application)


Both viewers animate just fine in their own windows. The crash happens if one viewer is being destroyed while the other is actively rendering. Note that it only seems to crash if there are Text objects in each scene, and did not crash with the old (pre-3.6) Text implementation. 


Is this usage model ok in the first place? Robert, I read your post in this recent thread in which you advise against manually destroying viewers. Should I assume that I was just lucky in getting away with this until now? The new Text implementation seems to be the only thing that triggers the crash.


In case anybody is interested, the crash happens due to this sequence of calls:
- ~CompositeViewer() calls GraphicsContext::close(), which deletes its State
- ~CompositeViewer() then destroys its osgViewer::View, which in turn destroys its Camera
- ~Camera() eventually calls osgText::releaseGLObjects() with a null State.
- osgText::releaseGLObjects(null) deletes text-related objects (Programs) on ALL contexts
- The other CompositeViewer, which is actively rendering its Text on another context, crashes with an access violation since its Text-related Programs were just deleted.


Thanks,
Ravi

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12269

PostPosted: Tue Dec 18, 2018 9:24 am    Post subject:
osgText crash with multiple Viewers
Reply with quote

Hi Ravi,


My guess is that the new text implementation isn't the cause of the crash, only it's the straw that broke the camels back, and actually there is an underlying limitation with the OSG w..r.t you specific usage case.


Could you create a small test program that reproduces the crash.  Details on your OS/dev tools/hardware will be useful too.



Cheers.

Robert.



On Tue, 18 Dec 2018 at 08:50, Ravi Mathur < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:
Hello all,

I'm seeing a crash on the OpenSceneGraph-3.6 branch that occurs when I have two CompositeViewers that contain Text objects in their scenes. My simplified scenario is this:
- 2 CompositeViewers, each in singlethreaded mode, but being run at the same time in separate threads (via OpenThreads::Thread wrappers)
- The viewers do not share scenes or contexts, and each has a single Text object as its scene
- Each viewer is destroyed immediately after its run() loop returns (needed for my application)


Both viewers animate just fine in their own windows. The crash happens if one viewer is being destroyed while the other is actively rendering. Note that it only seems to crash if there are Text objects in each scene, and did not crash with the old (pre-3.6) Text implementation. 


Is this usage model ok in the first place? Robert, I read your post in this recent thread in which you advise against manually destroying viewers. Should I assume that I was just lucky in getting away with this until now? The new Text implementation seems to be the only thing that triggers the crash.


In case anybody is interested, the crash happens due to this sequence of calls:
- ~CompositeViewer() calls GraphicsContext::close(), which deletes its State
- ~CompositeViewer() then destroys its osgViewer::View, which in turn destroys its Camera
- ~Camera() eventually calls osgText::releaseGLObjects() with a null State.
- osgText::releaseGLObjects(null) deletes text-related objects (Programs) on ALL contexts
- The other CompositeViewer, which is actively rendering its Text on another context, crashes with an access violation since its Text-related Programs were just deleted.


Thanks,
Ravi

_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
ravidavi
User


Joined: 06 Nov 2015
Posts: 57

PostPosted: Tue Dec 18, 2018 7:29 pm    Post subject:
osgText crash with multiple Viewers
Reply with quote

Hi Robert, yes I'm working on a standalone test program now. Multithreaded crashes are often hard to reproduce in a vacuum, but as soon as I have something I'll post here.

I'm running on Win10, Nvidia GTX 980 (latest drivers), Visual Studio 2013, OpenSceneGraph-3.6 branch.


Ravi


On Tue, Dec 18, 2018 at 4:24 AM Robert Osfield < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:
Hi Ravi,


My guess is that the new text implementation isn't the cause of the crash, only it's the straw that broke the camels back, and actually there is an underlying limitation with the OSG w..r.t you specific usage case.


Could you create a small test program that reproduces the crash.  Details on your OS/dev tools/hardware will be useful too.



Cheers.

Robert.



On Tue, 18 Dec 2018 at 08:50, Ravi Mathur < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:
Hello all,

I'm seeing a crash on the OpenSceneGraph-3.6 branch that occurs when I have two CompositeViewers that contain Text objects in their scenes. My simplified scenario is this:
- 2 CompositeViewers, each in singlethreaded mode, but being run at the same time in separate threads (via OpenThreads::Thread wrappers)
- The viewers do not share scenes or contexts, and each has a single Text object as its scene
- Each viewer is destroyed immediately after its run() loop returns (needed for my application)


Both viewers animate just fine in their own windows. The crash happens if one viewer is being destroyed while the other is actively rendering. Note that it only seems to crash if there are Text objects in each scene, and did not crash with the old (pre-3.6) Text implementation. 


Is this usage model ok in the first place? Robert, I read your post in this recent thread in which you advise against manually destroying viewers. Should I assume that I was just lucky in getting away with this until now? The new Text implementation seems to be the only thing that triggers the crash.


In case anybody is interested, the crash happens due to this sequence of calls:
- ~CompositeViewer() calls GraphicsContext::close(), which deletes its State
- ~CompositeViewer() then destroys its osgViewer::View, which in turn destroys its Camera
- ~Camera() eventually calls osgText::releaseGLObjects() with a null State.
- osgText::releaseGLObjects(null) deletes text-related objects (Programs) on ALL contexts
- The other CompositeViewer, which is actively rendering its Text on another context, crashes with an access violation since its Text-related Programs were just deleted.


Thanks,
Ravi

_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
ravidavi
User


Joined: 06 Nov 2015
Posts: 57

PostPosted: Wed Dec 19, 2018 6:23 pm    Post subject:
osgText crash with multiple Viewers
Reply with quote

OK I created a small standalone program that shows the crash (attached).

To trigger the crash:
  1. Run debug version of osgmultiwindowtesttext. It will open 2 windows (Viewers) that contain text "Scene1" and "Scene2"
  2. Close one window -> it might crash. If it crashes, see debug info
  3. If it doesn't crash, then close the other window -> 2 new windows will be created -> go back to step 2
You may have to repeat step 2 many times (20 or more) before you see the crash. The crash happens if the closed Viewer is destroyed while the open Viewer is in the render stage for the Text.


During debug, the thread for the Viewer being destroyed will likely be in the ~Camera() destructor. Meanwhile, the thread for the active Viewer will be in its rendering traversal, at State::apply() for the Text's Program. See my initial post for the codepath that ends up triggering the crash.


As I said before, I'm running on Win10, Nvidia GTX 980 (latest drivers), Visual Studio 2013, OpenSceneGraph-3.6 branch (although it happens with 3.6.3 tag also).


I'm perfectly happy if the conclusion ends up being "don't destroy a Viewer while another one is running". It's easy for me to pause all active Viewers while destroying one.


Thanks,
Ravi

On Tue, Dec 18, 2018 at 2:28 PM Ravi Mathur < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:
Hi Robert, yes I'm working on a standalone test program now. Multithreaded crashes are often hard to reproduce in a vacuum, but as soon as I have something I'll post here.

I'm running on Win10, Nvidia GTX 980 (latest drivers), Visual Studio 2013, OpenSceneGraph-3.6 branch.


Ravi


On Tue, Dec 18, 2018 at 4:24 AM Robert Osfield < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:
Hi Ravi,


My guess is that the new text implementation isn't the cause of the crash, only it's the straw that broke the camels back, and actually there is an underlying limitation with the OSG w..r.t you specific usage case.


Could you create a small test program that reproduces the crash.  Details on your OS/dev tools/hardware will be useful too.



Cheers.

Robert.



On Tue, 18 Dec 2018 at 08:50, Ravi Mathur < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:
Hello all,

I'm seeing a crash on the OpenSceneGraph-3.6 branch that occurs when I have two CompositeViewers that contain Text objects in their scenes. My simplified scenario is this:
- 2 CompositeViewers, each in singlethreaded mode, but being run at the same time in separate threads (via OpenThreads::Thread wrappers)
- The viewers do not share scenes or contexts, and each has a single Text object as its scene
- Each viewer is destroyed immediately after its run() loop returns (needed for my application)


Both viewers animate just fine in their own windows. The crash happens if one viewer is being destroyed while the other is actively rendering. Note that it only seems to crash if there are Text objects in each scene, and did not crash with the old (pre-3.6) Text implementation. 


Is this usage model ok in the first place? Robert, I read your post in this recent thread in which you advise against manually destroying viewers. Should I assume that I was just lucky in getting away with this until now? The new Text implementation seems to be the only thing that triggers the crash.


In case anybody is interested, the crash happens due to this sequence of calls:
- ~CompositeViewer() calls GraphicsContext::close(), which deletes its State
- ~CompositeViewer() then destroys its osgViewer::View, which in turn destroys its Camera
- ~Camera() eventually calls osgText::releaseGLObjects() with a null State.
- osgText::releaseGLObjects(null) deletes text-related objects (Programs) on ALL contexts
- The other CompositeViewer, which is actively rendering its Text on another context, crashes with an access violation since its Text-related Programs were just deleted.


Thanks,
Ravi

_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts Add multiple OverlayNode. osgsim General 0 Sun Jun 09, 2019 2:30 am View latest post
No new posts Running multiple (independent) viewer... Aneoshun General 2 Wed May 22, 2019 4:49 pm View latest post
No new posts Memory not being released, causing crash Juanelm General 1 Thu May 16, 2019 10:15 pm View latest post
No new posts Colored Bounding Box over osgText::Text dhhabyc General 1 Fri Apr 05, 2019 12:43 pm View latest post
No new posts osgText::Text dissapears when reparen... dhhabyc General 1 Wed Mar 27, 2019 1:48 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP