Re: [osg-users] Heap Corruption

2017-01-11 Thread Théo Nassour
Hello Heitbrink,

I'll try you're solution, and then i ll tell you ,
Thanks


d_a_heitbrink wrote:
> What threading model are you using?
> 
> One thing you need to be conscious of is when you update/modify your 
> scenegraph and who is using it at that time. Some operations might better be 
> served using different callback mechanisms, such as using 
> viewer->addUpdateOperation.
> 
> You might try switching your threading model to single threaded, and see if 
> that improves/ or changes the situation. This may or may be related to the 
> issue, heap corruption errors are notoriously difficult to debug.
> 
> Also keep in mind when you get a heap corruption exception, what is happening 
> behind the scenes is typically for debug builds every X number of heap 
> operations, the CRT will check the consistency of the heap. If it fails then, 
> it throws a exception. Often the location of what corrupts the memory is not 
> related to where it is detected. You can use:
> 
> _CrtSetDbgFlag
> _CrtCheckMemory
> 
> To have some control over when and how often the CRT checks the heap. If you 
> are really aggressive about this, this will totally kill performance.


--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=69954#69954





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Heap Corruption

2017-01-11 Thread Théo Nassour
Hello Bruno,
 How to provide a deallocator ?
Thanks in advance

Bruno Oliveira wrote:
> Another possibility is that your code is allocating and deallocating memory 
> in separate module DLLs. However, in Windows, each DLL has separate memory 
> spaces and that cannot be done.
> 
> 
> You should check if that's the case by any reason (e.g. creating a 
> osg::ref_ptr in a dll of your own and allowing osg::ref_ptr to be deallocaed 
> automatically by another dll module).
> 
> This is solved by providing proper deallocators.
> 
> 
> 2017-01-10 12:04 GMT+00:00 Voerman, L. < ()>:
> 
> > Hi Théo,I think you basically found out that the osg notify system is not 
> > thread safe, the call to osg::Notify from 
> > osg130-osgUtild.dll!osgUtil::CullVisitor::apply(osg::Drawable & drawable) 
> > Line 1036    C++
> > 
> >     OSG_NOTICE<<"CullVisitor::apply(Geode&) detected NaN,"
> > is probably running in parallel with a different thread calling osg::Notify 
> > as well while triggering a resize of the buffer (too). 
> > Setting OSG_NOTIFY_LEVEL=WARN will probably avoid this crash.
> > 
> > 
> > Regards, Laurens.
> > 
> > 
> > On Tue, Jan 10, 2017 at 12:39 PM, Alberto Luaces < ()> wrote:
> > 
> > > Ok, the next I would do is to see what is OSG trying to print in this
> > > stack frame (the ninth from the beginning):
> > > 
> > >      osg130-osgUtild.dll!std::operator<< > > >(std::basic_ostream & _Ostr, const char * 
> > > _Val) Line 806    C++
> > > 
> > > maybe that could serve as a hint...
> > > 
> > > --
> > > Alberto
> > > 
> > > ___
> > > osg-users mailing list
> > >  ()
> > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org 
> > > (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org)
> > > 
> > > 
> > > 
> > 
> > 
> > 
> > 
> > 
> > 
> > ___
> > osg-users mailing list
> >  ()
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org 
> > (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org)
> > 
> > 
> 
> 
>  --
> Post generated by Mail2Forum


--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=69953#69953





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Heap Corruption

2017-01-10 Thread David Heitbrink
What threading model are you using?

One thing you need to be conscious of is when you update/modify your scenegraph 
and who is using it at that time. Some operations might better be served using 
different callback mechanisms, such as using viewer->addUpdateOperation.

You might try switching your threading model to single threaded, and see if 
that improves/ or changes the situation. This may or may be related to the 
issue, heap corruption errors are notoriously difficult to debug.

Also keep in mind when you get a heap corruption exception, what is happening 
behind the scenes is typically for debug builds every X number of heap 
operations, the CRT will check the consistency of the heap. If it fails then, 
it throws a exception. Often the location of what corrupts the memory is not 
related to where it is detected. You can use:

_CrtSetDbgFlag
_CrtCheckMemory

To have some control over when and how often the CRT checks the heap. If you 
are really aggressive about this, this will totally kill performance.

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=69952#69952





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Heap Corruption

2017-01-10 Thread Bruno Oliveira
If you managed to solve the problem, forget it.
Else, take a look at this:

http://stackoverflow.com/questions/7705724/shared-memory-in-dlls

2017-01-10 13:26 GMT+00:00 Théo Nassour :

> Hi every one, and thanks for you're replies,
>
> I am sorry Bruno but, i havent understood what you Said. Can you explain
> more please :
>
> > Another possibility is that your code is allocating and deallocating
> memory in separate module DLLs. However, in Windows, each DLL has separate
> memory spaces and that cannot be done.
> >
> >
> > You should check if that's the case by any reason (e.g. creating a
> osg::ref_ptr in a dll of your own and allowing osg::ref_ptr to be
> deallocaed automatically by another dll module).
> >
> > This is solved by providing proper deallocators.
> >
>
>
> And Voerman
> Thanks and will disable All osg notify in this case, cause we are using
> commong logging from Nugget packages.
>
>
> Thank you!
>
> Cheers,
> Théo
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=69950#69950
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Heap Corruption

2017-01-10 Thread Théo Nassour
Hi every one, and thanks for you're replies,

I am sorry Bruno but, i havent understood what you Said. Can you explain more 
please :

> Another possibility is that your code is allocating and deallocating memory 
> in separate module DLLs. However, in Windows, each DLL has separate memory 
> spaces and that cannot be done. 
> 
> 
> You should check if that's the case by any reason (e.g. creating a 
> osg::ref_ptr in a dll of your own and allowing osg::ref_ptr to be deallocaed 
> automatically by another dll module). 
> 
> This is solved by providing proper deallocators. 
> 


And Voerman 
Thanks and will disable All osg notify in this case, cause we are using commong 
logging from Nugget packages.


Thank you!

Cheers,
Théo

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=69950#69950





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Heap Corruption

2017-01-10 Thread Bruno Oliveira
Another possibility is that your code is allocating and deallocating memory
in separate module DLLs. However, in Windows, each DLL has separate memory
spaces and that cannot be done.

You should check if that's the case by any reason (e.g. creating a
osg::ref_ptr in a dll of your own and allowing osg::ref_ptr to be
deallocaed automatically by another dll module).
This is solved by providing proper deallocators.

2017-01-10 12:04 GMT+00:00 Voerman, L. :

> Hi Théo,
> I think you basically found out that the osg notify system is not thread
> safe, the call to osg::Notify from
> osg130-osgUtild.dll!osgUtil::CullVisitor::apply(osg::Drawable & drawable)
> Line 1036C++
> OSG_NOTICE<<"CullVisitor::apply(Geode&) detected NaN,"
> is probably running in parallel with a different thread calling
> osg::Notify as well while triggering a resize of the buffer (too).
> Setting OSG_NOTIFY_LEVEL=WARN will probably avoid this crash.
>
> Regards, Laurens.
>
> On Tue, Jan 10, 2017 at 12:39 PM, Alberto Luaces  wrote:
>
>> Ok, the next I would do is to see what is OSG trying to print in this
>> stack frame (the ninth from the beginning):
>>
>>  osg130-osgUtild.dll!std::operator<<> >(std::basic_ostream & _Ostr, const char *
>> _Val) Line 806C++
>>
>> maybe that could serve as a hint...
>>
>> --
>> Alberto
>>
>> ___
>> osg-users mailing list
>> osg-users@lists.openscenegraph.org
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Heap Corruption

2017-01-10 Thread Voerman, L.
Hi Théo,
I think you basically found out that the osg notify system is not thread
safe, the call to osg::Notify from
osg130-osgUtild.dll!osgUtil::CullVisitor::apply(osg::Drawable & drawable)
Line 1036C++
OSG_NOTICE<<"CullVisitor::apply(Geode&) detected NaN,"
is probably running in parallel with a different thread calling osg::Notify
as well while triggering a resize of the buffer (too).
Setting OSG_NOTIFY_LEVEL=WARN will probably avoid this crash.

Regards, Laurens.

On Tue, Jan 10, 2017 at 12:39 PM, Alberto Luaces  wrote:

> Ok, the next I would do is to see what is OSG trying to print in this
> stack frame (the ninth from the beginning):
>
>  osg130-osgUtild.dll!std::operator<< >(std::basic_ostream & _Ostr, const char *
> _Val) Line 806C++
>
> maybe that could serve as a hint...
>
> --
> Alberto
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Heap Corruption

2017-01-10 Thread Alberto Luaces
Ok, the next I would do is to see what is OSG trying to print in this
stack frame (the ninth from the beginning):

 osg130-osgUtild.dll!std::operator<<(std::basic_ostream & _Ostr, const char * _Val) 
Line 806C++

maybe that could serve as a hint...

-- 
Alberto

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Heap Corruption

2017-01-10 Thread Théo Nassour
Hi,

Yes in fact this is one of my libraries, and it is in Debug x64, and i have 
checked : 
/MDd also


Thank you!

Cheers,
Théo

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=69945#69945





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Heap Corruption

2017-01-10 Thread Alberto Luaces
"Théo Nassour" writes:

>>SICLAV.OsgRendering.dll!SICLAV::nodes::Tree3D::accept(osg::NodeVisitor & 
>> nv) Line 31C++

Hi Théo, is that library in its "Debug" configuration?

-- 
Alberto

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Heap Corruption

2017-01-10 Thread Théo Nassour
Hi,

I am working on an application with the current configuration : 
WPF, CLI/C++ (for the communication between c++ and c#), c++ for OSG.
I am using VS2015 C++11.

I am getting always Heap Corruption Exception :
Here is the Stack trace:

 ucrtbased.dll!_calloc_base()Unknown
 ucrtbased.dll!_free_dbg()Unknown
 osg130-osgd.dll!operator delete(void * block) Line 21C++
 osg130-osgd.dll!std::_Deallocate(void * _Ptr, unsigned __int64 _Count, 
unsigned __int64 _Sz) Line 139C++
 osg130-osgd.dll!std::allocator::deallocate(char * _Ptr, unsigned 
__int64 _Count) Line 639C++
 
osg130-osgd.dll!std::basic_stringbuf::overflow(int _Meta) Line 182C++
 msvcp140d.dll!std::basic_streambuf::xsputn(const char * _Ptr, __int64 _Count) Line 411C++
 msvcp140d.dll!std::basic_streambuf::sputn(const char * _Ptr, __int64 _Count) Line 209C++
 osg130-osgUtild.dll!std::operator<<(std::basic_ostream & _Ostr, const char * _Val) 
Line 806C++
 osg130-osgUtild.dll!osgUtil::CullVisitor::apply(osg::Drawable & drawable) 
Line 1036C++
 osg130-osgd.dll!osg::NodeVisitor::apply(osg::Geometry & drawable) Line 92  
  C++
 osg130-osgd.dll!osg::Geometry::accept(osg::NodeVisitor & nv) Line 39C++
 osg130-osgd.dll!osg::Group::traverse(osg::NodeVisitor & nv) Line 63C++
 osg130-osgd.dll!osg::NodeVisitor::traverse(osg::Node & node) Line 189
C++
 
osg130-osgUtild.dll!osgUtil::CullVisitor::handle_cull_callbacks_and_traverse(osg::Node
 & node) Line 322C++
 osg130-osgUtild.dll!osgUtil::CullVisitor::apply(osg::Geode & node) Line 
974C++
 osg130-osgd.dll!osg::Geode::accept(osg::NodeVisitor & nv) Line 37C++
 osg130-osgd.dll!osg::Group::traverse(osg::NodeVisitor & nv) Line 63C++
 osg130-osgd.dll!osg::NodeVisitor::traverse(osg::Node & node) Line 189
C++
 
osg130-osgUtild.dll!osgUtil::CullVisitor::handle_cull_callbacks_and_traverse(osg::Node
 & node) Line 322C++
 osg130-osgUtild.dll!osgUtil::CullVisitor::apply(osg::Transform & node) 
Line 1247C++
 osg130-osgd.dll!osg::NodeVisitor::apply(osg::MatrixTransform & node) Line 
157C++
 osg130-osgd.dll!osg::MatrixTransform::accept(osg::NodeVisitor & nv) Line 
37C++
 osg130-osgd.dll!osg::Switch::traverse(osg::NodeVisitor & nv) Line 41C++
 osg130-osgd.dll!osg::NodeVisitor::traverse(osg::Node & node) Line 189
C++
 
osg130-osgUtild.dll!osgUtil::CullVisitor::handle_cull_callbacks_and_traverse(osg::Node
 & node) Line 322C++
 osg130-osgUtild.dll!osgUtil::CullVisitor::apply(osg::Group & node) Line 
1224C++
 osg130-osgUtild.dll!osgUtil::CullVisitor::apply(osg::Switch & node) Line 
1315C++
>SICLAV.OsgRendering.dll!SICLAV::nodes::Tree3D::accept(osg::NodeVisitor & 
> nv) Line 31C++
 osg130-osgd.dll!osg::Switch::traverse(osg::NodeVisitor & nv) Line 41C++
 osg130-osgd.dll!osg::NodeVisitor::traverse(osg::Node & node) Line 189
C++
 
osg130-osgUtild.dll!osgUtil::CullVisitor::handle_cull_callbacks_and_traverse(osg::Node
 & node) Line 322C++
 osg130-osgUtild.dll!osgUtil::CullVisitor::apply(osg::Group & node) Line 
1224C++
 osg130-osgUtild.dll!osgUtil::CullVisitor::apply(osg::Switch & node) Line 
1315C++
 osg130-osgd.dll!osg::Switch::accept(osg::NodeVisitor & nv) Line 40C++
 osg130-osgd.dll!osg::Group::traverse(osg::NodeVisitor & nv) Line 63C++
 osg130-osgd.dll!osg::NodeVisitor::traverse(osg::Node & node) Line 189
C++
 
osg130-osgUtild.dll!osgUtil::CullVisitor::handle_cull_callbacks_and_traverse(osg::Node
 & node) Line 322C++
 osg130-osgUtild.dll!osgUtil::CullVisitor::apply(osg::Transform & node) 
Line 1247C++
 osg130-osgd.dll!osg::NodeVisitor::apply(osg::MatrixTransform & node) Line 
157C++
 osg130-osgd.dll!osg::MatrixTransform::accept(osg::NodeVisitor & nv) Line 
37C++
 osg130-osgd.dll!osg::Group::traverse(osg::NodeVisitor & nv) Line 63C++
 osg130-osgd.dll!osg::NodeVisitor::traverse(osg::Node & node) Line 189
C++
 
osg130-osgUtild.dll!osgUtil::CullVisitor::handle_cull_callbacks_and_traverse(osg::Node
 & node) Line 322C++
 osg130-osgUtild.dll!osgUtil::CullVisitor::apply(osg::Transform & node) 
Line 1247C++
 osg130-osgd.dll!osg::NodeVisitor::apply(osg::MatrixTransform & node) Line 
157C++
 osg130-osgd.dll!osg::MatrixTransform::accept(osg::NodeVisitor & nv) Line 
37C++
 osg130-osgd.dll!osg::Switch::traverse(osg::NodeVisitor & nv) Line 41C++
 osg130-osgd.dll!osg::NodeVisitor::traverse(osg::Node & node) Line 189
C++
 
osg130-osgUtild.dll!osgUtil::CullVisitor::handle_cull_callbacks_and_traverse(osg::Node
 & node) Line 322C++
 osg130-osgUtild.dll!osgUtil::CullVisitor::apply(osg::Group & node) Line 
1224C++
 

[osg-users] Heap corruption

2015-09-03 Thread Julie Green
Hi,

I'm trying to draw a quadric surface, which is modifying each frame, and I'm 
getting a heap corruption error. I guess the problem is in calculating 
function, or in update callback, but can't find it in the debugger. 

Code:

void SurfaceCalculationThread::reCalculateSurface()
{
mutex.lock();
float x, y, z;
int i = 0;
float t=time->elapsedTime();
for (x = -polygonLength; x <= polygonLength; x += 1.0f)
{
for (y = -polygonLength; y <= polygonLength; y += 1.0f)
{
(*oldVertexArray)[i].set((*newVertexArray)[i]);
z = computeZ(x, y, t);
(*newVertexArray)[i].set(osg::Vec3f(x, y, z));
i++;
}
}
geometry->setVertexArray(oldVertexArray);
geometry->setUpdateCallback(new 
UpdateSurfaceCallback(conditionVariable));

osgUtil::SmoothingVisitor *smoothingVisitor = new 
osgUtil::SmoothingVisitor();
smoothingVisitor->smooth(*geometry);
smoothingVisitor->setName("normal");

conditionVariable->wait();
mutex.unlock();

}

void UpdateSurfaceCallback::operator()(osg::Node *node, osg::NodeVisitor *nv)
{
traverse(node, nv);
conditionVariable->wakeAll();
};




Thanks for your help!

Cheers,
Julie

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=65007#65007





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Heap corruption

2015-09-03 Thread Julie Green
Hi Robert.

My task is to calculate surface in a thread. I've set the DataVariance of 
Drawable leaf to Dynamic, but still get the crash.

Julie.

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=65010#65010





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Heap corruption

2015-09-03 Thread Robert Osfield
Hi Julie,

On 3 September 2015 at 14:22, Julie Green  wrote:

> My task is to calculate surface in a thread. I've set the DataVariance of
> Drawable leaf to Dynamic, but still get the crash.
>

We can only provide general pointers.  We don't have the code to run, we've
only seen a tiny fragment of your program, your doing stuff in ways that
isn't something possibly is advisable, for reasons that only you are aware
of.

The best we can is suggest that you use a debugger or thread debugging
tools. If you need assistance then colleagues/supervises may well be the
best people to help.

Robert.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Heap corruption

2015-09-03 Thread Robert Osfield
Hi Julie,

I'm not why you are using a separate thread here as the syncronization will
likely just serialize the operations anyway, it'll be more efficient to do
all the work in the update callback directly as you won't thash the cache.

As for the cause of the crash, if you running the viewer multi-threaded
(which is the default) then the static objects left in draw traversal will
run in a parallel with the next frame.  Now if the state+drawables being
dispatches in by the draw thread aren't actually static but are being
modified by the update traversal from the main thread (or other thread)
you'll get a conflict.

The way to avoid this conflict is to set the DataVariance on the StateSet
and Drawable objects that you are modifying to DYNAMIC.  The draw traversal
holds back the next frame till all the DYNMAIC StateSet and Drawable are
dispatched to OpenGL thus avoid thread conflict.  An alternative to this
would be to run the viewer SingleThreaded or CullDrawThreadPerContext by
setting the threading model using
viewer.setThreadingModel(osgViewer::Viewer::SingleThreaded);

Robert.


On 3 September 2015 at 13:06, Julie Green  wrote:

> Hi,
>
> I'm trying to draw a quadric surface, which is modifying each frame, and
> I'm getting a heap corruption error. I guess the problem is in calculating
> function, or in update callback, but can't find it in the debugger.
>
> Code:
>
> void SurfaceCalculationThread::reCalculateSurface()
> {
> mutex.lock();
> float x, y, z;
> int i = 0;
> float t=time->elapsedTime();
> for (x = -polygonLength; x <= polygonLength; x += 1.0f)
> {
> for (y = -polygonLength; y <= polygonLength; y += 1.0f)
> {
> (*oldVertexArray)[i].set((*newVertexArray)[i]);
> z = computeZ(x, y, t);
> (*newVertexArray)[i].set(osg::Vec3f(x, y, z));
> i++;
> }
> }
> geometry->setVertexArray(oldVertexArray);
> geometry->setUpdateCallback(new
> UpdateSurfaceCallback(conditionVariable));
>
> osgUtil::SmoothingVisitor *smoothingVisitor = new
> osgUtil::SmoothingVisitor();
> smoothingVisitor->smooth(*geometry);
> smoothingVisitor->setName("normal");
>
> conditionVariable->wait();
> mutex.unlock();
>
> }
>
> void UpdateSurfaceCallback::operator()(osg::Node *node, osg::NodeVisitor
> *nv)
> {
> traverse(node, nv);
> conditionVariable->wakeAll();
> };
>
>
>
>
> Thanks for your help!
>
> Cheers,
> Julie
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=65007#65007
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org