Hi,

I have a macbook pro and an iMac with Xcode 4.3.3. If i built OSG in the mbp 
using cmake i doesn't have any problems and all the examples and my own 
programs run correctly. But in the iMac, after repeating the same steps, every 
time a node if deleted in the same program, the program halts with a memory 
error indicating that the pointer has been freed. 

I had check every line of code. The graph is as simple as:


Code:


- (void) regenerateSceneAndRedraw
{
    scene->removeChildren(0, escena->getNumChildren());
    assert(scene->getNumChildren() == 0);

    {
       osg::ref_ptr<osg::Geode> geode;
       osg::ref_ptr<osg::ShapeDrawable> shape;

       shape = new osg::ShapeDrawable();
       shape->setShape(new osg::Box(osg::Vec3(-3, 0., 0.), 2., 2., 1.));
       shape->setColor(osg::Vec4(0., 0., 1., 1.));

       geode = new osg::Geode;
       geode->addChild(shape.get());
    }
    
    [self setNeedsDisplay: YES];
}





I have my own Cocoa wrapper class based on ViewerCocoa.m which holds and 
osg::ref_ptr<osg::Group> pointer to the root node of the scene. 


Code:

@interface xViewerOSG : ViewerCocoa
{
    @private
    
        osg::ref_ptr<osg::Group> scene_root;

        id<xViewerProtocol> drawingDataDelegate;
}





The first time it works perfectly, the second one it crashes. Here is the 
callstack:

frame #0: 0x00007fff90cf96bc libsystem_c.dylib`malloc_error_break
    frame #1: 0x00007fff90cf9805 libsystem_c.dylib`free + 318
    frame #2: 0x00007fff959ca702 
libstdc++.6.dylib`std::string::_Rep::_M_dispose(std::allocator<char> const&) + 
60
    frame #3: 0x00007fff959ca740 libstdc++.6.dylib`std::basic_string<char, 
std::char_traits<char>, std::allocator<char> >::~basic_string() + 44
    frame #4: 0x000000010abec054 libosg.80.dylib`osg::Object::~Object() + 116
    frame #5: 0x000000010aa897e9 libosg.80.dylib`osg::BufferData::~BufferData() 
+ 89
    frame #6: 0x000000010a72db75 libgeomcomp.dylib`osg::Array::~Array() + 21 at 
Array:125
    frame #7: 0x000000010a72e17d 
libgeomcomp.dylib`osg::TemplateArray<osg::Vec4f, (osg::Array::Type)11, 4, 
5126>::~TemplateArray() + 45 at Array:195
    frame #8: 0x000000010a72db95 
libgeomcomp.dylib`osg::TemplateArray<osg::Vec4f, (osg::Array::Type)11, 4, 
5126>::~TemplateArray() + 21 at Array:195
    frame #9: 0x000000010a72dbb8 
libgeomcomp.dylib`osg::TemplateArray<osg::Vec4f, (osg::Array::Type)11, 4, 
5126>::~TemplateArray() + 24 at Array:195
    frame #10: 0x000000010ac2a2ea 
libosg.80.dylib`osg::Referenced::signalObserversAndDelete(bool, bool) const + 
298
    frame #11: 0x000000010aa4d4a4 libosg.80.dylib`osg::Referenced::unref() 
const + 84
    frame #12: 0x000000010ab2e980 
libosg.80.dylib`osg::ref_ptr<osg::Array>::~ref_ptr() + 48
    frame #13: 0x000000010ab1dbc5 
libosg.80.dylib`osg::ref_ptr<osg::Array>::~ref_ptr() + 21
    frame #14: 0x000000010ab5bb5a 
libosg.80.dylib`osg::Geometry::ArrayData::~ArrayData() + 42
    frame #15: 0x000000010ab1db05 
libosg.80.dylib`osg::Geometry::ArrayData::~ArrayData() + 21
    frame #16: 0x000000010ab11c94 libosg.80.dylib`osg::Geometry::~Geometry() + 
164
    frame #17: 0x000000010ab11be5 libosg.80.dylib`osg::Geometry::~Geometry() + 
21
    frame #18: 0x000000010ab11b88 libosg.80.dylib`osg::Geometry::~Geometry() + 
24
    frame #19: 0x000000010ac2a2ea 
libosg.80.dylib`osg::Referenced::signalObserversAndDelete(bool, bool) const + 
298
    frame #20: 0x000000010aa4d4a4 libosg.80.dylib`osg::Referenced::unref() 
const + 84
    frame #21: 0x000000010ab0f5dd 
libosg.80.dylib`osg::ref_ptr<osg::Drawable>::operator=(osg::Drawable*) + 125
    frame #22: 0x000000010b60e3a7 
libosgUtil.80.dylib`osgUtil::RenderLeaf::reset() + 55
    frame #23: 0x000000010b6097e4 
libosgUtil.80.dylib`osgUtil::CullVisitor::reset() + 436
    frame #24: 0x000000010b7abe70 
libosgUtil.80.dylib`osgUtil::SceneView::cullStage(osg::Matrixd const&, 
osg::Matrixd const&, osgUtil::CullVisitor*, osgUtil::StateGraph*, 
osgUtil::RenderStage*, osg::Viewport*) + 2096
    frame #25: 0x000000010b7ab545 
libosgUtil.80.dylib`osgUtil::SceneView::cull() + 5557
    frame #26: 0x000000010ca8de0a 
libosgViewer.80.dylib`osgViewer::Renderer::cull_draw() + 1194
    frame #27: 0x000000010ca8eb4f 
libosgViewer.80.dylib`osgViewer::Renderer::operator()(osg::GraphicsContext*) + 
47
    frame #28: 0x000000010ab7e025 
libosg.80.dylib`osg::GraphicsContext::runOperations() + 549
    frame #29: 0x000000010cb031c0 
libosgViewer.80.dylib`osgViewer::ViewerBase::renderingTraversals() + 9408
    frame #30: 0x000000010cb00cf2 
libosgViewer.80.dylib`osgViewer::ViewerBase::frame(double) + 178
    frame #31: 0x000000010a7d7a73 xViewer`-[ViewerCocoa drawRect:] + 163 at 
ViewerCocoa.mm:902
    frame #32: 0x00007fff8c40d97a AppKit`-[NSView _drawRect:clip:] + 3758
    frame #33: 0x00007fff8c43ab4f AppKit`-[NSView 
_recursiveDisplayAllDirtyWithLockFocus:visRect:] + 1583
    frame #34: 0x00007fff8c40af55 AppKit`-[NSView 
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
 + 1032
    frame #35: 0x00007fff8c40c20a AppKit`-[NSView 
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
 + 5821
    frame #36: 0x00007fff8c40c20a AppKit`-[NSView 
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
 + 5821
    frame #37: 0x00007fff8c40c20a AppKit`-[NSView 
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
 + 5821
    frame #38: 0x00007fff8c40c20a AppKit`-[NSView 
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
 + 5821
    frame #39: 0x00007fff8c40a44f AppKit`-[NSThemeFrame 
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
 + 270
    frame #40: 0x00007fff8c40586f AppKit`-[NSView 
_displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] + 4755
    frame #41: 0x00007fff8c3fe2ed AppKit`-[NSView displayIfNeeded] + 1676
    frame #42: 0x00007fff8c3fda2d 
AppKit`_handleWindowNeedsDisplayOrLayoutOrUpdateConstraints + 648
    frame #43: 0x00007fff8befcf40 Foundation`__NSFireTimer + 102
    frame #44: 0x00007fff969e4934 
CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
    frame #45: 0x00007fff969e4486 CoreFoundation`__CFRunLoopDoTimer + 534
    frame #46: 0x00007fff969c4e11 CoreFoundation`__CFRunLoopRun + 1617
    frame #47: 0x00007fff969c4486 CoreFoundation`CFRunLoopRunSpecific + 230
    frame #48: 0x00007fff905404d3 HIToolbox`RunCurrentEventLoopInMode + 277
    frame #49: 0x00007fff90547781 HIToolbox`ReceiveNextEventCommon + 355
    frame #50: 0x00007fff9054760e 
HIToolbox`BlockUntilNextEventMatchingListInMode + 62
    frame #51: 0x00007fff8c3c1e31 AppKit`_DPSNextEvent + 659
    frame #52: 0x00007fff8c3c1735 AppKit`-[NSApplication 
nextEventMatchingMask:untilDate:inMode:dequeue:] + 135
    frame #53: 0x00007fff8c3be071 AppKit`-[NSApplication run] + 470
    frame #54: 0x00007fff8c63a244 AppKit`NSApplicationMain + 867
    frame #55: 0x000000010a711362 xDesign`main + 34 at main.m:13
    frame #56: 0x000000010a711334 xDesign`start + 52

Has anyone experienced the same issue? Until Xcode 4.2 I didn't have any 
problem so i think that something is inconsistent in my the iMac because it 
works for in the Macbook. Reinstalling Xcode will be the last one try because i 
think the error is something stupid but subtle.

In this moment it doesn't neither building with gcc nor clang.

Any idea will be welcome.

Thank you!

Cheers,
Manuel

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





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to