DepthSortDescendingLess crash

Discussion area about developing or extending OGRE, adding plugins for it or building applications on it. No newbie questions please, use the Help forum for that.
Post Reply
User avatar
Mind Calamity
Ogre Magi
Posts: 1255
Joined: Sat Dec 25, 2010 2:55 pm
Location: Macedonia

DepthSortDescendingLess crash

Post by Mind Calamity » Sun Mar 02, 2014 9:25 pm

Really weird issue, I've spent a few days looking and dismantling my own code, and finally traced it to my base object that contains a scene node. It only happens on OpenGL, and I saw that it happens when there are 2 or more materials that use scene blending. (doesn't seem to happen if the camera is stationary, only when the camera moves)
It's definitely related to scene_blend because (as noted in the material file), if we comment any 2 of the scene_blend specifications the application doesn't crash.
Since it doesn't happen in any other mode other than Release. (not even RelWithDebInfo from CMake).
Visual Studio default debugger doesn't help at all.

This is what I got from WinDbg:

Code: Select all

(4bc.1688): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
ERROR: Symbol file could not be found. Defaulted to export symbols for C:\Users\MindCalamity\Documents\Visual Studio 2010\Projects\OGRE_GL_Bug\OGRE_GL_Bug\OgreMain.dll - 
eax=50c53904 ebx=02384688 ecx=55161660 edx=5093fb50 esi=02384678 edi=00afa590
eip=50932abe esp=0046f3ac ebp=0046f3c8 iopl=0 nv up ei pl zr na pe nc
cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00010246
OgreMain!Ogre::SharedPtr<Ogre::HardwareCounterBuffer>::destroy+0x545e:
50932abe 8b01 mov eax,dword ptr [ecx] ds:002b:55161660=????????
The above is basically a repost of my JIRA issue, the point of the repost is to bring some attention to the issue and possibly start a discussion on tracing/fixing it.

Reproduction code + binaries here

Tested on:
Windows 7.
Visual Studio 2010 SP1.
OGRE 1.10.0 at commit 56501ce from 24.02.2014.

Anyone have an idea why this wouldn't be reproducible in Debug and RelWithDebInfo (CMake) ?
Last edited by Mind Calamity on Tue Mar 04, 2014 2:05 pm, edited 1 time in total.
0 x
BitBucket username changed to iboshkov (from MindCalamity)
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt

User avatar
c6burns
Beholder
Posts: 1511
Joined: Fri Feb 22, 2013 4:44 am
Location: Deep behind enemy lines

Re: scene_blend crash in 1.10 OpenGL in Release only (Window

Post by c6burns » Sun Mar 02, 2014 10:38 pm

Repro'd with your dlls, but when I swap in my release dlls from 1.10 the issue dissappears. VC10 Express, Win7, 1.10 head, boost 1.53

It shows an arrow moving up and down
0 x

User avatar
holocronweaver
Google Summer of Code Student
Google Summer of Code Student
Posts: 273
Joined: Mon Oct 29, 2012 8:52 pm
Location: Princeton, NJ

Re: scene_blend crash in 1.10 OpenGL in Release only (Window

Post by holocronweaver » Sun Mar 02, 2014 11:12 pm

HardwareCounterBuffers are not supported by GL RS. Are you using GL3+?

Further, could you provide a stack trace? I don't have my Windows system running at the moment.
0 x

User avatar
c6burns
Beholder
Posts: 1511
Joined: Fri Feb 22, 2013 4:44 am
Location: Deep behind enemy lines

Re: scene_blend crash in 1.10 OpenGL in Release only (Window

Post by c6burns » Sun Mar 02, 2014 11:28 pm

It's plain ol rendersystem GL. It might be just updating to 1.10 head fixes it and it got pulled at a bad time? Not sure exactly how that would be true though

Anyway, I'm not sure exactly what changes between RelWithDebInfo and Release but it seems like more than is strictly necessary in order to get debug symbols. In my Ogre.sln, it turns on incremental linking and a few other things I noticed. All you really need to change from Release is C++/General->Debug Info = Prog DB /Zi and Linker/Debugging->Generate Deb Info = Yes /DEBUG
0 x

User avatar
Mind Calamity
Ogre Magi
Posts: 1255
Joined: Sat Dec 25, 2010 2:55 pm
Location: Macedonia

Re: scene_blend crash in 1.10 OpenGL in Release only (Window

Post by Mind Calamity » Mon Mar 03, 2014 10:17 am

I just re-cloned the repository and recompiled, no fix - still the same.

Enabling debug symbols doesn't fix it, neither does enabling incremental linking.
0 x
BitBucket username changed to iboshkov (from MindCalamity)
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt

User avatar
c6burns
Beholder
Posts: 1511
Joined: Fri Feb 22, 2013 4:44 am
Location: Deep behind enemy lines

Re: scene_blend crash in 1.10 OpenGL in Release only (Window

Post by c6burns » Mon Mar 03, 2014 11:47 am

So it does still crash with /Zi and /DEBUG? You should at least get a meaningful backtrace and disassembly now.
0 x

User avatar
Mind Calamity
Ogre Magi
Posts: 1255
Joined: Sat Dec 25, 2010 2:55 pm
Location: Macedonia

Re: scene_blend crash in 1.10 OpenGL in Release only (Window

Post by Mind Calamity » Mon Mar 03, 2014 2:40 pm

c6burns wrote:So it does still crash with /Zi and /DEBUG? You should at least get a meaningful backtrace and disassembly now.
Got it! I enabled debug symbols on my program but not on OgreMain (heh, no sleep). Anyways, I got a stack trace:

Code: Select all

 	OgreMain.dll!std::_Insertion_sort1<Ogre::RenderablePass *,Ogre::QueuedRenderableCollection::DepthSortDescendingLess,Ogre::RenderablePass>(Ogre::RenderablePass * _First, Ogre::RenderablePass * _Last, Ogre::QueuedRenderableCollection::DepthSortDescendingLess _Pred, Ogre::RenderablePass * __formal)  Line 3666 + 0x12 bytes	C++
 	OgreMain.dll!std::_Stable_sort<Ogre::RenderablePass *,int,Ogre::RenderablePass,Ogre::QueuedRenderableCollection::DepthSortDescendingLess>(Ogre::RenderablePass * _First, Ogre::RenderablePass * _Last, int _Count, std::_Temp_iterator<Ogre::RenderablePass> & _Tempbuf, Ogre::QueuedRenderableCollection::DepthSortDescendingLess _Pred)  Line 3979 + 0x13 bytes	C++
>	OgreMain.dll!Ogre::SceneManager::renderBasicQueueGroupObjects(Ogre::RenderQueueGroup * pGroup, Ogre::QueuedRenderableCollection::OrganisationMode om)  Line 3086 + 0x3e6 bytes	C++
 	OgreMain.dll!Ogre::SceneManager::_renderQueueGroupObjects(Ogre::RenderQueueGroup * pGroup, Ogre::QueuedRenderableCollection::OrganisationMode om)  Line 3068 + 0x11 bytes	C++
 	OgreMain.dll!Ogre::SceneManager::renderVisibleObjectsDefaultSequence()  Line 2354	C++
 	OgreMain.dll!Ogre::SceneManager::_renderScene(Ogre::Camera * camera, Ogre::Viewport * vp, bool includeOverlays)  Line 1565	C++
 	OgreMain.dll!Ogre::Camera::_renderScene(Ogre::Viewport * vp, bool includeOverlays)  Line 430	C++
 	OgreMain.dll!Ogre::RenderTarget::_updateViewport(Ogre::Viewport * viewport, bool updateStatistics)  Line 201	C++
 	OgreMain.dll!Ogre::RenderTarget::_updateAutoUpdatedViewports(bool updateStatistics)  Line 180	C++
 	OgreMain.dll!Ogre::RenderTarget::updateImpl()  Line 156	C++
 	OgreMain.dll!Ogre::RenderTarget::update(bool swap)  Line 616	C++
 	OgreMain.dll!Ogre::RenderSystem::_updateAllRenderTargets(bool swapBuffers)  Line 123	C++
 	OgreMain.dll!Ogre::Root::_updateAllRenderTargets()  Line 1412	C++
 	OgreMain.dll!Ogre::Root::renderOneFrame()  Line 983 + 0x7 bytes	C++
 	OGRE_GL_Bug.exe!main()  Line 50	C++
 	OGRE_GL_Bug.exe!__tmainCRTStartup()  Line 555 + 0x17 bytes	C
Happens in SceneManager::renderBasicQueueGroupObjects, at:

Code: Select all

3083        RenderPriorityGroup* pPriorityGrp = groupIt.getNext(); // here, I think
3084
3085        // Sort the queue first
3086        pPriorityGrp->sort(mCameraInProgress);
BTW, I went to branch v1-9 to see if it's there as well, and yep - it's here.

Visual Studio doesn't seem to show pointer values in release mode, so I can't see which pointer is null. (if you know of a way to toggle that, share it)
0 x
BitBucket username changed to iboshkov (from MindCalamity)
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 4041
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 216
Contact:

Re: scene_blend crash in 1.10 OpenGL in Release only (Window

Post by dark_sylinc » Tue Mar 04, 2014 4:04 am

DepthSortDescendingLess?

It could be this long standing problem: http://www.ogre3d.org/forums/viewtopic.php?f=4&t=35417
There is a "solution" and that is to remove the RealEqual call. Note particles' order could will start going crazy from frame to frame.

You may have 2 entities too closed together in your scene and that's why it's crashing.

The offending code is going to get obliterated in 2.1 and I will take joy in it.

Edit: The reason scene_blend triggers the crash, is because that causes the RQ to force depth sorting (when alpha blending)
0 x

User avatar
Mind Calamity
Ogre Magi
Posts: 1255
Joined: Sat Dec 25, 2010 2:55 pm
Location: Macedonia

Re: scene_blend crash in 1.10 OpenGL in Release only (Window

Post by Mind Calamity » Tue Mar 04, 2014 10:42 am

dark_sylinc wrote:DepthSortDescendingLess?

It could be this long standing problem: http://www.ogre3d.org/forums/viewtopic.php?f=4&t=35417
There is a "solution" and that is to remove the RealEqual call. Note particles' order could will start going crazy from frame to frame.

You may have 2 entities too closed together in your scene and that's why it's crashing.

The offending code is going to get obliterated in 2.1 and I will take joy in it.

Edit: The reason scene_blend triggers the crash, is because that causes the RQ to force depth sorting (when alpha blending)
Yep, you nailed it. Setting the floating point mode to Consistent in D3D9 also reproduces the issue, whereas it's no problem in Fast mode.

Why not do a fix in 1.10/the current/next version (not major) of OGRE. Because IIRC OGRE 2.x is a long-term project.

Edit: Removing

Code: Select all

if (Math::RealEqual(adepth, bdepth))
{
    // Must return deterministic result, doesn't matter what
    return a.pass < b.pass;
}
Fixed the crash, although as mentioned in the other thread this could cause the particle depth fighting. So I changed it to your B solution mentioned here. This also fixes it. I haven't tried it with particles yet.

Non-Crashing code:

Code: Select all

if (Math::RealEqual(adepth, bdepth))
{
    // Must return deterministic result, doesn't matter what
    return a.pass->getHash() < b.pass->getHash();
}
0 x
BitBucket username changed to iboshkov (from MindCalamity)
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 4041
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 216
Contact:

Re: scene_blend crash in 1.10 OpenGL in Release only (Window

Post by dark_sylinc » Tue Mar 04, 2014 4:49 pm

Mind Calamity wrote:

Code: Select all

if (Math::RealEqual(adepth, bdepth))
{
    // Must return deterministic result, doesn't matter what
    return a.pass->getHash() < b.pass->getHash();
}
While the Math::RealEqual(adepth, bdepth) remains, the code may still crash sooner or later.
0 x

User avatar
Mind Calamity
Ogre Magi
Posts: 1255
Joined: Sat Dec 25, 2010 2:55 pm
Location: Macedonia

Re: scene_blend crash in 1.10 OpenGL in Release only (Window

Post by Mind Calamity » Tue Mar 04, 2014 7:49 pm

dark_sylinc wrote:
Mind Calamity wrote:

Code: Select all

if (Math::RealEqual(adepth, bdepth))
{
    // Must return deterministic result, doesn't matter what
    return a.pass->getHash() < b.pass->getHash();
}
While the Math::RealEqual(adepth, bdepth) remains, the code may still crash sooner or later.
Well, what is a viable alternative then ? How are you gonna go about fixing this in 2.0 ? And what is your reasoning for postponing it ?
0 x
BitBucket username changed to iboshkov (from MindCalamity)
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 4041
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 216
Contact:

Re: scene_blend crash in 1.10 OpenGL in Release only (Window

Post by dark_sylinc » Tue Mar 04, 2014 8:03 pm

Mind Calamity wrote:Well, what is a viable alternative then ? How are you gonna go about fixing this in 2.0 ?
By reimplementing the whole Render Queue from scratch with a approach similar to this one. The particular issue in question, is to quantize the depth values.
Mind Calamity wrote:And what is your reasoning for postponing it ?
Time constraints :)
We want to release 2.0 ASAP. A full refactor of the RQ is big.
0 x

User avatar
Mind Calamity
Ogre Magi
Posts: 1255
Joined: Sat Dec 25, 2010 2:55 pm
Location: Macedonia

Re: DepthSortDescendingLess crash

Post by Mind Calamity » Tue Mar 04, 2014 11:39 pm

Wouldn't implementing quantizing depth values be more of a papercut ?

Maybe a sort of temporary fix, since 2.0 has a decently long development timeline before it can be usable.
Speaking of which, is it in any way usable in it's current form, and what exactly has been changed ?

Do you maintain a changelog and maybe a to-do list ?
0 x
BitBucket username changed to iboshkov (from MindCalamity)
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 4041
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 216
Contact:

Re: DepthSortDescendingLess crash

Post by dark_sylinc » Wed Mar 05, 2014 12:12 am

Mind Calamity wrote:Wouldn't implementing quantizing depth values be more of a papercut ?
Perhaps. Can't rememeber the reason I didn't do it back then. I remember something holding me back.
Mind Calamity wrote:Maybe a sort of temporary fix, since 2.0 has a decently long development timeline before it can be usable.
Speaking of which, is it in any way usable in it's current form, and what exactly has been changed ?
It is quite usable in its current form.
There is a porting manual. The original odt file is in the repo now.
Mind Calamity wrote:Do you maintain a changelog and maybe a to-do list ?
Tindalos notes.
Most notably non working features:
TagPoints aren't working.
Scene queries (i.e. ray queries)
NodeAnimationTrack
StaticGeometry
A few components (i.e. Terrain, Volume)
0 x

Post Reply