Discussion:
[Opensg-users] Segfault in OSGTypedGeoIntegralProperty.h
Victor Haefner
2014-11-07 11:48:07 UTC
Permalink
Hi,

I updated the OpenSG version of my Project (from an older v2 to the current
one)
Now I have massive problems with strange segfaults:

Valgrind:

InvalidWrite|====|Invalid write of size 1|
||Call stack:|
/usr/local/include/OpenSG/OSGTypedGeoIntegralProperty.h|161|0x709B8D: void
OSG::TypedGeoIntegralProperty<OSG::GeoUInt8PropertyDesc>::push_back<int>(int
const&)|
/usr/lib/opensg/libOSGDrawable.so.2.0.0||0x11E7D48D:
OSG::makeSphereGeo(unsigned short, float)|
/home/victor/Projects/polyvr/src/PolyVR.cpp|74|0x7A8EF1:
OSG::initPolyVR(int, char**)|
/home/victor/Projects/polyvr/src/main.cpp|18|0x57E845: main|
||Address 0x0 is not stack'd, malloc'd or (recently) free'd|
||Valgrind found 1 errors!|


Backtrace:

#0 0x709b8d setValue<int>(index=0, val=4, this=0x7fffc96f5e10)
(/usr/local/include/OpenSG/OSGTypedGeoIntegralProperty.h:161)
#1 ?? OSG::TypedGeoIntegralProperty<OSG::GeoUInt8PropertyDesc>::push_back<int>
(this=0x7fffc96f5e10, val=<optimized out>)
(/usr/local/include/OpenSG/OSGTypedGeoIntegralProperty.h:176)
#2 0x7fffeb43348e OSG::makeSphereGeo(unsigned short, float) ()
(/usr/lib/opensg/libOSGDrawable.so.2.0.0:??)
#3 0x7a8ef2 OSG::initPolyVR(argc=***@entry=1, argv=***@entry=0x7fffffffe2d8)
(PolyVR.cpp:74)
#4 0x57e846 main(argc=1, argv=0x7fffffffe2d8) (main.cpp:18)

Now comes the strange part:
- The problem occured on all machines I tried it on, Ati, Nvidia, but all
Ubuntu 14.04
- The problem vanishes when I comment this type of code throughout my
project files:

GeoUInt8PropertyRecPtr Type = GeoUInt8Property::create();
GeoUInt32PropertyRecPtr Length = GeoUInt32Property::create();
GeoPnt3fPropertyRecPtr Pos = GeoPnt3fProperty::create();
GeoVec3fPropertyRecPtr Norms = GeoVec3fProperty::create();
GeoUInt32PropertyRecPtr Indices = GeoUInt32Property::create();
SimpleMaterialRecPtr Mat = SimpleMaterial::create();
GeoVec2fPropertyRecPtr Tex = GeoVec2fProperty::create();

Type->addValue(type);
Length->addValue(inds.size());

//positionen und Normalen
for(uint i=0;i<pos.size();i++) {
Pos->addValue(pos[i]);
Norms->addValue(norms[i]);
if (texs.size() == pos.size()) Tex->addValue(texs[i]);
}

for(uint i=0;i<inds.size();i++) {
Indices->addValue(inds[i]);
}

Mat->setDiffuse(Color3f(0.8,0.8,0.6));
Mat->setAmbient(Color3f(0.4, 0.4, 0.2));
Mat->setSpecular(Color3f(0.1, 0.1, 0.1));

GeometryRecPtr geo = Geometry::create();
geo->setTypes(Type);
geo->setLengths(Length);
geo->setIndices(Indices);
geo->setPositions(Pos);
geo->setNormals(Norms);
geo->setTexCoords(Tex);
geo->setMaterial(Mat);

Just by having this code in the executale produces the crashes..
I don't even call it.
- If I comment the code above my project starts, I can import COLLADA files
and create primitive geometries, but I still get random segfaults..
- All of this must be related to some recent changes in OpenSG

I will continue to search, but I am running out of ideas :(

UPDATE: The above is still valid, I refined it to the following:

osgInit(argc,argv);
GeoUInt8PropertyRecPtr Type = GeoUInt8Property::create();
Type->addValue(GL_LINES); // <-- segfault here

#0 ?? OSG::initPolyVR (argc=***@entry=1, argv=***@entry=0x7fffffffe2d8)
#1 0x57e7c6 main(argc=1, argv=0x7fffffffe2d8)

InvalidWrite|====|Invalid write of size 1|
||Call stack:|
/usr/local/include/OpenSG/OSGTypedGeoIntegralProperty.h|161|0x7A97B3:
OSG::initPolyVR(int, char**)|
/home/victor/Projects/polyvr/src/main.cpp|18|0x57E7C5: main|
||Address 0x0 is not stack'd, malloc'd or (recently) free'd|
||Valgrind found 1 errors!|


UPDATE 2: get the same with 09geometry_water2.cpp

#0 0x40be92 setValue<int>(index=0, val=7, this=0x7fffd9233b40)
(/usr/local/include/OpenSG/OSGTypedGeoIntegralProperty.h:161)
#1 ?? push_back<int> (val=<optimized out>, this=0x7fffd9233b40)
(/usr/local/include/OpenSG/OSGTypedGeoIntegralProperty.h:176)
#2 ?? addValue<int> (val=<optimized out>, this=0x7fffd9233b40)
(/usr/local/include/OpenSG/OSGTypedGeoIntegralProperty.h:169)
#3 ?? createScenegraph () (/home/victor/Projects/polyvr/src/main.cpp:48)
#4 0x40b333 main(argc=1, argv=<optimized out>) (09geometry_water2.cpp:123)



Best regards,
Victor
Gerrit Voß
2014-11-07 12:18:30 UTC
Permalink
Hi,
Post by Victor Haefner
Hi,
osgInit(argc,argv);
GeoUInt8PropertyRecPtr Type = GeoUInt8Property::create();
Type->addValue(GL_LINES); // <-- segfault here
#1 0x57e7c6 main(argc=1, argv=0x7fffffffe2d8)
InvalidWrite|====|Invalid write of size 1|
||Call stack:|
OSG::initPolyVR(int, char**)|
/home/victor/Projects/polyvr/src/main.cpp|18|0x57E7C5: main|
||Address 0x0 is not stack'd, malloc'd or (recently) free'd|
||Valgrind found 1 errors!|
hmm, just looking at this, it looks like osgInit fails to initialize all
the types, hence GeoUInt8Property::create creates nothing.
One way would be to use a debugger and trace through
GeoUInt8Property::create and see why it returns NULL.

Another, could you do a 'export OSG_LOG_LEVEL=10' in your shell and send
the output. That should trace a lot of the initialization part.
Post by Victor Haefner
UPDATE 2: get the same with 09geometry_water2.cpp
#0 0x40be92 setValue<int>(index=0, val=7, this=0x7fffd9233b40)
(/usr/local/include/OpenSG/OSGTypedGeoIntegralProperty.h:161)
#1 ?? push_back<int> (val=<optimized out>, this=0x7fffd9233b40)
(/usr/local/include/OpenSG/OSGTypedGeoIntegralProperty.h:176)
#2 ?? addValue<int> (val=<optimized out>, this=0x7fffd9233b40)
(/usr/local/include/OpenSG/OSGTypedGeoIntegralProperty.h:169)
#3 ?? createScenegraph ()
(/home/victor/Projects/polyvr/src/main.cpp:48)
Post by Victor Haefner
#4 0x40b333 main(argc=1, argv=<optimized out>)
(09geometry_water2.cpp:123)
this one looks more weird, why does it suddenly jump into:

createScenegraph () from (/home/victor/Projects/polyvr/src/main.cpp:48)

Another thing that worries me,
Post by Victor Haefner
/usr/local/include/OpenSG/OSGTypedGeoIntegralProperty.h|161|0x709B8D: void
OSG::TypedGeoIntegralProperty<OSG::GeoUInt8PropertyDesc>::push_back<int>(int
Post by Victor Haefner
const&)|
the first part, the inline code, comes from /usr/local, the second part
from /usr/lib. Could it be that there are 2 OpenSG2 installs, one
in /usr and one in /usr/local and those get mixed up ?

kind regards
gerrit




------------------------------------------------------------------------------
Victor Haefner
2014-11-07 13:36:05 UTC
Permalink
Hi Gerrit,
Post by Gerrit Voß
hmm, just looking at this, it looks like osgInit fails to initialize all
the types, hence GeoUInt8Property::create creates nothing.
One way would be to use a debugger and trace through
GeoUInt8Property::create and see why it returns NULL.
Another, could you do a 'export OSG_LOG_LEVEL=10' in your shell and send
the output. That should trace a lot of the initialization part.
..log level, I will try this next time :)
Post by Gerrit Voß
createScenegraph () from (/home/victor/Projects/polyvr/src/main.cpp:48)
/home/victor/Projects/polyvr/src/main.cpp is my project, I just copy pasted
the tutorial code there to test it, sorry for the confusion.
Post by Gerrit Voß
the first part, the inline code, comes from /usr/local, the second part
from /usr/lib. Could it be that there are 2 OpenSG2 installs, one
in /usr and one in /usr/local and those get mixed up ?
..I feel stupid.. yep, that was the bug :)
its funny, I tried it on different nodes.. but they all have nearly the
same configuration.
Thanks a lot for the help!!

kind regards
gerrit




------------------------------------------------------------------------------
Loading...