Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In some cases, osgDB::writeNodeFile write 0kb osgb #1288

Open
autel-liuxiaozi opened this issue Dec 20, 2023 · 5 comments
Open

In some cases, osgDB::writeNodeFile write 0kb osgb #1288

autel-liuxiaozi opened this issue Dec 20, 2023 · 5 comments

Comments

@autel-liuxiaozi
Copy link

autel-liuxiaozi commented Dec 20, 2023

Hello,I think it's a bug and recurrent Very occasionally. using osg3.4.0

I uses osg lib to write osgb file , code like this


osg::ref_ptr<osg::Group> group = new osg::Group;
for(const auto& child : tile->children_)   
{
    if (child == nullptr)
        continue;
    
    osg::ref_ptr<osg::PagedLOD> paged_lod = new osg::PagedLOD;
    
    paged_lod->setRangeMode(osg::PagedLOD::PIXEL_SIZE_ON_SCREEN);
    paged_lod->setCenterMode(osg::PagedLOD::USER_DEFINED_CENTER);
    
    Vector3f center = child->box_.center();
    Vector3f corner = child->box_.corner(BoundingBox3f::CornerType(0));
    
    paged_lod->setCenter(osg::Vec3f(center(0), center(1), center(2)));
    
    const float radius = (center - corner).norm();
    
    if (!child->children_.empty())
    {
        const int level = GeometricErrorToLevel(child->geometric_error_);
        const float pixel_size = radius / LevelToGSD(level);
        
        paged_lod->addChild(child->osg_node_, 0, pixel_size);
        paged_lod->setFileName(1, child->url_ + ".osgb");
        paged_lod->setRange(1, pixel_size, FLT_MAX);
    }
    else
    {
        paged_lod->addChild(child->osg_node_, 0, FLT_MAX);
    }
    group->addChild(paged_lod);
}
if(group->getNumChildren() > 0)
    osgDB::writeNodeFile(*group, file_name new osgDB::Options("WritelmageHint=IncludeFile"));
for(auto& child : tile->children_)
    child = nullptr; //release tile after save

now demo crashes in osgDB::writeNodeFile(*group, file_name new osgDB::Options("WritelmageHint=IncludeFile"));

and have some error like this:
image

and saved osgb is like this:
image

could anyone help me to locate this bug? @robertosfield @andesengineering @openscenegraph

thank you all very much

@autel-liuxiaozi
Copy link
Author

autel-liuxiaozi commented Dec 20, 2023

it's in a omp condition, just like this:

#pragma omp parallel for schedule(dynamic,1)
for(int i=0;i<node.size();++i)
{
SaveTileAsOsgb(names[i],tile);
}

and this stack info like this:
image

@robertosfield
Copy link
Collaborator

My best guess is memory corruption somewhere in your application. Your code snippet has references to class that aren't part of the OSG so we can only guess what functionality they might have.

You have all your application, all your data and you have access so all of the OSG code base, while we only have the later. You are the one best place to investigate the problem. Try building with a debugger and stepping through the code, or try running your application in a tool like valgrind to see if can spot any memory corruption.

@autel-liuxiaozi
Copy link
Author

autel-liuxiaozi commented Dec 20, 2023

My best guess is memory corruption somewhere in your application. Your code snippet has references to class that aren't part of the OSG so we can only guess what functionality they might have.

You have all your application, all your data and you have access so all of the OSG code base, while we only have the later. You are the one best place to investigate the problem. Try building with a debugger and stepping through the code, or try running your application in a tool like valgrind to see if can spot any memory corruption.

ok, thank you. but this happens only when generate osgbs. so I guess it's related to osg library,and happens very occasionally

@robertosfield
Copy link
Collaborator

Memory corruption in one place can cause other parts to crash.

Even if it does turn out to be an OSG bug, at this point there isn't anything that others can help with given no others have reported this issue, we don't have a means of recreating the problem. You are the only one that has means to investigate.

@autel-liuxiaozi
Copy link
Author

OK, thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants