Hello everyone,
recently I encountered a sporadic crash in my App at same position upon calling function Renderer::draw() in osgViewer/Renderer.cpp. The crash happend at
DEBUG_MESSAGE<<"draw() got SceneView "<<sceneView<<std::endl; (screenshots of callstack are attached)
and triggerd an exception via a string of basic streambuf operations very deep down to msvcp100d.dll in dbgheap.c
/*
* If this ASSERT fails, a bad pointer has been passed in. It may be
* totally bogus, or it may have been allocated from another heap.
* The pointer MUST come from the 'local' heap.
*/
_ASSERTE(_CrtIsValidHeapPointer(pUserData)); ----> assertion error thrown, the heap pointer is invalid
In debug session I checked the call stack step by step and found that when putting "draw() got SceneView" in stringbuffer, functoin overflow of std::basic_stringbuf is triggerd, and subsequently
the deallocate step at :
if (_Mystate & _Allocated)
_Al.deallocate(_Oldptr, _Oldsize);
_Mystate |= _Allocated;
was executed. it tried to deallocate the buffer, pointed by "_Oldptr" with size "_Oldsize". But the size is smaller than the actual buffer length. Therefore the assertion error above was thrown.
Info to my App:
I enhance the viewer with osgWidget::WindowManager. My App recieves external data cyclic and renders boxes and lines in one data transmission framework. The API of this framework calls my viewer to render every 20ms, an example of this call:
framework::call_on_cycle () { // main thread
// process and storing incoming data
process_data();
myViewer->frame();
}
My App runs at DrawThreadPerContext mode and updates drawables in callback and setting them as DYNAMIC.
Is there anyone ever facing similar Problem? Or any ideas to analyse or sort this out? I will really appreciate any help.
Thank you
Regards,
Yuan