|Anonymous | Login||2019-04-22 13:09 MSK|
|My View | View Issues | Change Log | Roadmap|
|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0023345||Community||[OCCT] OCCT:Visualization||public||2012-07-25 13:40||2012-11-16 13:18|
|Platform||Windows||OS||VC++ 2008||OS Version||32 bit|
|Product Version||[OCCT] 6.5.3|
|Target Version||[OCCT] 6.5.4||Fixed in Version||[OCCT] 6.5.4|
|Summary||0023345: Crash when destroying OpenGl_Element|
|Description||After compiling master/origin with the HEAD revision 0023342 my MFC application started crashing (opening and then closing the document/viewer was enough). The crash in my case occurred only when closing the document (the handle to OpenGl_Context was Null).|
I discovered that in the issue 023226 "Extend OpenGl_Context to store map of shared GPU resources" some new functionalities were added. One of them causes the crash.
And so, in OpenGl_Element.hxx a new method - Destroy - was added that makes the following call:
However, it is possible that the provided 'const Handle(OpenGl_Context)&' to the context is a Null one and that causes the crash.
My suggestion is to check the context against 'Null' and if it's not the case to call the 'Release' method.
if(theContext.IsNull() == Standard_False)
The solves the problem in my case.
|Steps To Reproduce||Here is the reproducer:|
1. Compile the MFC samples provided with OCCT using the 0023342 revision of OCCT (origin/master branch)
2. Run the Triangulation sample.
3. Press the "Mesh" button.
4. Exit the application.
This reproduces the problem on my WinXP machine. The application finishes up in the OpenGl_PrimitiveArray::Release (as described in the below section) and crashes because of the Null context handle.
Interesting is, that if nothing is shown (no meshing done) in the application, no problem occurs.
and documentation updates
|The root problem is caused by the method OpenGl_PrimitiveArray::Release.|
In line 1555, the method theContext->DelayedRelease (myVbos[anIter]); holds an Null context-handle and crashes.
|Tags||No tags attached.|
|Test case number||Not needed|
|Corresponding git branch pushed. Please review.|
This is incorrect by design - OpenGl_Element::Destroy() method needed to NEVER forget to release GPU resources. Thus all elements should be explicitly destroyed before OpenGl_Context.
Please provide full sample for your use case to prepare appropriate patch.
Thanks for reviewing the issue.
I have provided further information how to reproduce the problem in the issue description/information.
Hope this helps.
Just a couple of observations, maybe they help.
I have looked at the branch 23345_2 committed by kgv. In that form the samples still crash but with a couple of tweaks the problem seems to be solved:
- CViewer3dView in MFC samples does not inherit from OCC_3dView so that the cleaning code put in ~OCC_3dView() is not actually called. As first step, I put the cleaning code (ProcessLastView) to ~CViewer3dView()
- This solved the problem but only partially. If I run a sample (let's say Viewer3d) create an object (e.g sphere) and close the view everything is OK. But if I hover over an object in the viewer so that it gets highlighted or select it the application crashes closing the viewer.
- To solve this I noticed I had to nullify the handles to AIS_Shapes stored in CViewer3dDoc
- In that case no crash occurs anymore.
Again, as I don't have much experience with OpenGL I can't say if the root cause of the problem is solved by that but it seems to work.
Hope this helps
One more problem detected - this can be not enough to call
> AIS_InteractiveContext::RemoveAll (Standard_False);
to clean up all Interactive Objects.
There are several StdSelect_ViewerSelector3d instances present in AIS_InteractiveContext which holds SelectMgr_DataMapOfIntegerSensitive (StdSelect_ViewerSelector3d::myentities) and doesn't cleared by AIS_InteractiveContext::RemoveAll() call.
As workaround application may call:
> myAISContext->RemoveAll (Standard_False);
> Handle(StdSelect_ViewerSelector3d) aSel = myAISContext->MainSelector();
> if (!aSel.IsNull())
> aSel = myAISContext->LocalSelector();
> if (!aSel.IsNull())
But this extra code looks strange so it is probably better to perform it inside OCCT somehow.
I applied the workaround from kgv but still get crashes when working with local context.
The stack looks like this:
04B95320 (TKOpenGl): (filename not available): OpenGl_Context::DelayedRelease
04BAA510 (TKOpenGl): (filename not available): OpenGl_GraphicDriver::TriedronEcho
At the moment I don't have a reproducer (the crash occurs in our software but is 100% reproducible) so this note is for documentation purposes only.
edited on: 2012-10-08 17:42
just to clarify - your comment was about CR23345_3 branch?
1. No, I actually meant your suggestion (0021472) about StdSelect_ViewerSelector3d:
Handle(StdSelect_ViewerSelector3d) aSel = myAISContext->MainSelector();
2. I haven't noticed the branch CR23345_3 so far. But I have compiled it just right now and it worked!
Thanks for the hint
|I propose the current state of CR23345_3 to be tested for integration to 6.5.4 beta, and remaining problems to be treated within a separate issue|
Branch CR23345_3 (and master from occt-products) was compiled on Linux and Windows platforms and tested.
occt: master dd8a4ce9
Timestamp: 2012-10-12 12:56:23
|0023345: Crash when destroying OpenGl_Element
OpenGl_PrimitiveArray::Release() - avoid possible NULL-pointer dereference
OpenGl_GraphicDriver::RemoveView() - release GL resources within removing last view
Fixed OCC280 test command - do not remove old view until new one is initialized
|mod - src/OpenGl/OpenGl_GraphicDriver_7.cxx|
|mod - src/OpenGl/OpenGl_PrimitiveArray.cxx|
|mod - src/OpenGl/OpenGl_Structure.cxx|
|mod - src/OpenGl/OpenGl_Structure.hxx|
|mod - src/QABugs/QABugs_17.cxx|
|2012-07-25 13:40||Pawel||New Issue|
|2012-07-25 13:40||Pawel||Assigned To||=> Pawel|
|2012-07-25 13:52||Pawel||Note Added: 0021147|
|2012-07-25 13:52||Pawel||Assigned To||Pawel => bugmaster|
|2012-07-25 13:52||Pawel||Status||new => resolved|
|2012-07-25 17:20||abv||Assigned To||bugmaster => kgv|
|2012-07-25 17:37||kgv||Note Added: 0021148|
|2012-07-25 17:37||kgv||Assigned To||kgv => Pawel|
|2012-07-25 17:37||kgv||Status||resolved => feedback|
|2012-07-25 18:35||Pawel||Additional Information Updated||View Revisions|
|2012-07-25 18:47||Pawel||Note Added: 0021150|
|2012-07-25 18:47||Pawel||Status||feedback => assigned|
|2012-07-25 18:47||Pawel||Status||assigned => feedback|
|2012-07-25 18:49||Pawel||Steps to Reproduce Updated||View Revisions|
|2012-07-25 18:49||Pawel||Note Deleted: 0021150|
|2012-07-25 18:50||Pawel||Steps to Reproduce Updated||View Revisions|
|2012-07-25 18:51||Pawel||Note Added: 0021151|
|2012-07-25 18:51||Pawel||Status||feedback => assigned|
|2012-07-25 18:51||Pawel||Assigned To||Pawel => kgv|
|2012-07-25 18:53||Pawel||Steps to Reproduce Updated||View Revisions|
|2012-08-01 10:50||kgv||Assigned To||kgv => san|
|2012-08-01 11:42||Pawel||Note Added: 0021195|
|2012-09-13 11:52||kgv||Note Added: 0021472|
|2012-09-14 15:38||san||Assigned To||san => kgv|
|2012-10-08 16:47||Pawel||Note Added: 0021681|
|2012-10-08 17:41||kgv||Note Added: 0021682|
|2012-10-08 17:42||kgv||Note Edited: 0021682||View Revisions|
|2012-10-08 18:37||Pawel||Note Added: 0021688|
|2012-10-10 17:41||abv||Status||assigned => resolved|
|2012-10-10 17:44||abv||Assigned To||kgv => bugmaster|
|2012-10-10 17:44||abv||Status||resolved => reviewed|
|2012-10-10 17:53||abv||Note Added: 0021711|
|2012-10-10 18:08||mkv||Assigned To||bugmaster => mkv|
|2012-10-16 10:16||mkv||Note Added: 0021778|
|2012-10-16 10:16||mkv||Test case number||=> Not needed|
|2012-10-16 10:16||mkv||Assigned To||mkv => bugmaster|
|2012-10-16 10:16||mkv||Status||reviewed => tested|
|2012-10-16 15:21||kgv||Changeset attached||=> occt master dd8a4ce9|
|2012-10-16 15:21||kgv||Assigned To||bugmaster => kgv|
|2012-10-16 15:21||kgv||Status||tested => verified|
|2012-10-16 15:21||kgv||Resolution||open => fixed|
|2012-11-12 11:53||kgv||Relationship added||related to 0023500|
|2012-11-12 12:58||kgv||Relationship added||related to 0023226|
|2012-11-16 13:13||bugmaster||Fixed in Version||=> 6.5.4|
|2012-11-16 13:18||bugmaster||Status||verified => closed|
|Copyright © 2000 - 2019 MantisBT Team|