Crash at HardwareBuffer Lock ...killed ManualObject section?

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
User avatar
Beauty
OGRE Community Helper
OGRE Community Helper
Posts: 767
Joined: Wed Oct 10, 2007 2:36 pm
Location: Germany
x 39
Contact:

Crash at HardwareBuffer Lock ...killed ManualObject section?

Post by Beauty »

Hi,

a half year ago I wrote a new class for "raycasting to polygon level". (See code and comments)
Now I embedded this code for the vehicle and sensor simulation topic of my diploma thesis.

In general it works fine, but sometimes (e.g. after one minute of many queries) it causes a crash.
It happens while reading the content of a vertex element.

More specific: It happens while reading data from a ManualObject, without indices and the rendering OperationType is a triangle.
This works fine for more than hundred times (with the same ManuaObject).

Here is the C# code where it happens:

Code: Select all

VertexElement posEl = moData.vertexData.vertexDeclaration.FindElementBySemantic(VertexElementSemantic.VES_POSITION);
HardwareVertexBufferSharedPtr vBuff = moData.vertexData.vertexBufferBinding.GetBuffer(posEl.Source);

byte* pVertex = (byte*)vBuff.Lock(HardwareBuffer.LockOptions.HBL_READ_ONLY);    // <-- CRASH HERE
Looking to the debugger, I see the crash in this C++ line (of the Ogre wrapper):

Code: Select all

void* HardwareBuffer::Lock( Mogre::HardwareBuffer::LockOptions options )
{
	return static_cast<Ogre::HardwareBuffer*>(_native)->lock( (Ogre::HardwareBuffer::LockOptions)options );   // CRASH
}
There is an AccessViolationException, which can caused e.g. by a pointer problem.
The Ogre log file has no error or warning.
For me it looks like a problem with LOCK() to the HardWareBuffer.


Is there any idea what could be the reason or what I can do?

Ogre problem?
Hardware problem?

Currently my application still uses Ogre 1.6.5 (with the Glue of the Mogre wrapper).
Is there a real chance to solve the problem, when I update it to Ogre 1.7?
(Ogre 1.8 is still not available for C#.)

Would it be useful to compile/embedd debug libraries of Ogre/Mogre for deeper debugging?

Most of the time for my diploma thesis (university) is gone. The problem is realy disturbing my simulations.
I would be happy about suggestions ...
Last edited by Beauty on Thu Jul 12, 2012 12:36 am, edited 1 time in total.
Help to add information to the wiki. Also tiny edits will let it grow ... :idea:
Add your country to your profile ... it's interesting to know from where of the world you are.
User avatar
Beauty
OGRE Community Helper
OGRE Community Helper
Posts: 767
Joined: Wed Oct 10, 2007 2:36 pm
Location: Germany
x 39
Contact:

Re: Crash at HardwareBuffer Lock

Post by Beauty »

I made a tiny test:

I queried with 5 rays, without changing source or direction.
No object (including the ManualObject) in the scene was moved.
So there should be always the same 5 query results.
After almost 9000 ray queries on polygon level the crash happened.


But very interesting:
In the last rendered image I see that one surface is gone.
(Each vessel wall of the pipe is rendered by it's own ManualObject section with OperationType OT_TriangleStrip.)

Image

Why the triangles seems to be gone?
Are they gone forever or just for one rendered frame?? (if I could ignore the exception)

Would it make sense to change my code to use OT_TriangleList instead of OT_TriangleStrip to avoid the crashes?

Any other ideas?
Help to add information to the wiki. Also tiny edits will let it grow ... :idea:
Add your country to your profile ... it's interesting to know from where of the world you are.
CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
x 58
Contact:

Re: Crash at HardwareBuffer Lock

Post by CABAListic »

Assuming your debug trace is complete and the crash really happens in the line you posted, then it doesn't crash inside Ogre, but in the wrapper. There's only one pointer in that line, _native, so maybe that one got lost somewhere?
User avatar
Beauty
OGRE Community Helper
OGRE Community Helper
Posts: 767
Joined: Wed Oct 10, 2007 2:36 pm
Location: Germany
x 39
Contact:

Re: Crash at HardwareBuffer Lock

Post by Beauty »

Thanks for your answer.

I added a workaround by a try-catch block.
This avoids crashes, but always when an exception happens, a whole triangle strip is gone (and keeps gone).
I never had such things before adding my polygon raycasting code.

It seems so that the (read-only) code causes "killing" ManualObject sections.
As result the vertex buffer of the sections can't be accessed.
It's no hardware problem, because the same behaviour happens on an other PC, too.
CABAListic wrote: the crash really happens in the line you posted
Yes, the crash happens there.
But now I suppose, the source of the problem is somewhere/somewhat else. (Killing the section and dispose the related memory. So the pointer can't access it anymore.)

Here is a screenshot, showing the "damaged" ManualObject.
Image
Help to add information to the wiki. Also tiny edits will let it grow ... :idea:
Add your country to your profile ... it's interesting to know from where of the world you are.
User avatar
Beauty
OGRE Community Helper
OGRE Community Helper
Posts: 767
Joined: Wed Oct 10, 2007 2:36 pm
Location: Germany
x 39
Contact:

Re: Crash at HardwareBuffer Lock ...killed ManualObject sect

Post by Beauty »

In the "official topic" about my polygon ray query class I described my crash test results more detailed.
Here is repetition:


After some debugging it seems so that the crash happens, because a single section of the ManualObject get somehow "invalide".
In my application I catched the Exception and stopped polygon raycasting. Then my application is still running (instead of full crash). But one of my ManualObject sections isn't visible anymore in the Ogre render window.

My suggestion:
Sometimes somehow (by usage of my raycasting code) a single ManualObject section gets invalide.
So Ogre doesn't render it anymore.
And when my raycasting code tries to read the section content, there is a crash, because the memory (RAM on GPU) of the section seems to be disposed.
So the pointer (of the ManualObject section) points to a memory address, which doesn't exists anymore.

It's very strange, because the query works hundrets and thousands of times. And somewhen later there is a crash.
Even when nothing in the scene or ray properties are changed. All object positions/orientations are equal. Also the ray origin/direction is equal.
It works and works and works. Always the same situation. But somewhen there is a BAM.
I never had problems with "loosing ManualObject sections", It only happens while using my ray query code.
My ray query code is read-only (related to the GPU RAM). So why it should make invalide the allocated memory of a ManOb section?
I don't understand this.

Perhaps the same problem happens with Entity sections?
I didn't try it yet, but it could be possible.

If somebody has an idea, it would be nice if he tell it (in the referenced topic).

P.S.
I still use Ogre 1.6.
If this issue is based on a already fixed Ogre bug, please let me know.
Help to add information to the wiki. Also tiny edits will let it grow ... :idea:
Add your country to your profile ... it's interesting to know from where of the world you are.
Post Reply