OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

Valgrind osg 3.4.0


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> Submission
View previous topic :: View next topic  
Author Message
Sturm, Peter
Guest





PostPosted: Wed Jan 04, 2017 8:13 am    Post subject:
Valgrind osg 3.4.0
Reply with quote

Hello,

I have found following using valgrind:

==24954== Conditional jump or move depends on uninitialised value(s)
==24954== at 0x4B7A4E9: cos (in /lib/libm-2.19.so)
==24954== by 0x4983E79: osg::Quat::makeRotate(double, double, double, double) (in /MIL/SCTT/DEV/RTS/tmp/psturm/update/libosg.so.130)
==24954== by 0x4983F4A: osg::Quat::makeRotate(double, osg::Vec3d const&) (in /MIL/SCTT/DEV/RTS/tmp/psturm/update/libosg.so.130)
==24954== by 0x4572498: osgSim::DirectionalSector::computeMatrix() (in /MIL/SCTT/DEV/RTS/tmp/psturm/update/libosgSim.so.130)
==24954== by 0x45725D0: osgSim::DirectionalSector::setDirection(osg::Vec3f const&) (in /MIL/SCTT/DEV/RTS/tmp/psturm/update/libosgSim.so.130)
==24954== by 0x457264E: osgSim::DirectionalSector::DirectionalSector(osg::Vec3f const&, float, float, float, float) (in /MIL/SCTT/DEV/RTS/tmp/psturm/update/libosgSim.so.130)
==24954== by 0x41FA64F: LightPoint::addVertex(flt::Vertex&) (LightPointRecords.cpp:137)
==24954== by 0x41FC100: flt::VertexCN::readRecord(flt::RecordInputStream&, flt::Document&) (VertexRecords.cpp:114)
==24954== by 0x421885E: flt::RecordInputStream::readRecordBody(int, int, flt::Document&) (RecordInputStream.cpp:75)
==24954== by 0x4218ADD: flt::RecordInputStream::readRecord(flt::Document&) (RecordInputStream.cpp:40)
==24954== by 0x4211491: flt::VertexListRecord::readRecord(flt::RecordInputStream&, flt::Document&) (GeometryRecords.cpp:596)
==24954== by 0x421885E: flt::RecordInputStream::readRecordBody(int, int, flt::Document&) (RecordInputStream.cpp:75)
==24954== Uninitialised value was created by a heap allocation
==24954== at 0x402A6CC: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-x86-linux.so)
==24954== by 0x4276E72: operator new(unsigned int) (new_op.cc:52)
==24954== by 0x41FA5DE: LightPoint::addVertex(flt::Vertex&) (LightPointRecords.cpp:137)
==24954== by 0x41FC100: flt::VertexCN::readRecord(flt::RecordInputStream&, flt::Document&) (VertexRecords.cpp:114)
==24954== by 0x421885E: flt::RecordInputStream::readRecordBody(int, int, flt::Document&) (RecordInputStream.cpp:75)
==24954== by 0x4218ADD: flt::RecordInputStream::readRecord(flt::Document&) (RecordInputStream.cpp:40)
==24954== by 0x4211491: flt::VertexListRecord::readRecord(flt::RecordInputStream&, flt::Document&) (GeometryRecords.cpp:596)
==24954== by 0x421885E: flt::RecordInputStream::readRecordBody(int, int, flt::Document&) (RecordInputStream.cpp:75)
==24954== by 0x42049FA: FLTReaderWriter::readNode(std::istream&, osgDB::Options const*) const (ReaderWriterFLT.cpp:401)
==24954== by 0x420695C: FLTReaderWriter::readNode(std::string const&, osgDB::Options const*) const (ReaderWriterFLT.cpp:194)
==24954== by 0x44B1B81: osgDB::Registry::ReadNodeFunctor::doRead(osgDB::ReaderWriter&) const (in /MIL/SCTT/DEV/RTS/tmp/psturm/update/libosgDB.so.130)
==24954== by 0x44A95AE: osgDB::Registry::read(osgDB::Registry::ReadFunctor const&) (in /MIL/SCTT/DEV/RTS/tmp/psturm/update/libosgDB.so.130)

I believe, the message is created by

src/osgSim/Sector.cpp lines 220-247/363

The member _rollAngle is not intitialized then computeMatrix() is called after first call of

DirectionalSector::DirectionalSector(const osg::Vec3& direction,float horizLobeAngle, float vertLobeAngle, float lobeRollAngle, float fadeAngle)

The issue may be fixed, if _rollAngle is initialized with lobeRollAngle in the constructor first.

DirectionalSector::DirectionalSector(const osg::Vec3& direction,float horizLobeAngle, float vertLobeAngle, float lobeRollAngle, float fadeAngle):
Sector()
{
setDirection(direction);
setHorizLobeAngle(horizLobeAngle);
setVertLobeAngle(vertLobeAngle);
setLobeRollAngle(lobeRollAngle);
setFadeAngle(fadeAngle);
}

void DirectionalSector::computeMatrix()
{
double heading = atan2(_direction[0], _direction[1]);
double pitch = atan2(_direction[2], sqrt(_direction[0]*_direction[0] + _direction[1]*_direction[1]));
double roll = _rollAngle;

_local_to_LP.setRotate(osg::Quat(heading,osg::Vec3d(0.0, 0.0, -1.0)));
_local_to_LP.preMultRotate(osg::Quat(pitch, osg::Vec3d(1.0, 0.0, 0.0)));
_local_to_LP.preMultRotate(osg::Quat(roll, osg::Vec3d(0.0, 1.0, 0.0)));
}


void DirectionalSector::setDirection(const osg::Vec3& direction)
{
_direction = direction ;
computeMatrix() ;
}
[…]

void DirectionalSector::setLobeRollAngle(float angle)
{
_rollAngle = angle ;
computeMatrix() ;
}






Mit freundlichen Grüßen / Yours sincerely

Peter Sturm





Rheinmetall Defence Electronics GmbH
Brüggeweg 54
28309 Bremen / Germany
Sitz der Gesellschaft : Bremen
Amtsgericht Bremen HRB 9659
Geschäftsführung:
Helmut Möring
Thorsten Quade
Ulrich Sasse
Vorsitzender des Aufsichtsrats:
Gordon Hargreave
This email may contain confidential information. If you are not the intended addressee, or if the information provided in this email (including any attachments) is evidently not destined for you, kindly inform us promptly and delete the message received in error (including any attachments) by erasing it from all your computers and other storage devices or media and destroying any hard copies thereof. Any unauthorized processing, forwarding, disclosure, distribution, divulgation, storage, printout or other use of this message or its attachment is prohibited. If your system is infected or otherwise bugged by any virus that is carried by this email, we disclaim any liability whatsoever for the ensuing loss or damage unless caused by our intention or gross negligence.

------------------
Post generated by Mail2Forum
Back to top
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 10983

PostPosted: Wed Jan 04, 2017 1:05 pm    Post subject:
Valgrind osg 3.4.0
Reply with quote

Hi Peter,


Thanks for clear pointers to the cause of the uninitializaed variable usage - essentially computeMatrix() gets called prematurely.  I have restructured the problem constructor to ensure that the computeMatrix() only gets called after the variables have been initialized. 

The fix is now checked into git master, 3.4 and 3.2 branches:

   https://github.com/openscenegraph/OpenSceneGraph/commit/b5c4f461bc8a2ad86cb55ce9a01b5baf60c200b7


Could you test this and let me know how you get on,


Robert.


On 4 January 2017 at 08:12, Sturm, Peter < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:

Hello,
 
I have found following using valgrind:
 
==24954== Conditional jump or move depends on uninitialised value(s)
==24954==    at 0x4B7A4E9: cos (in /lib/libm-2.19.so)
==24954==    by 0x4983E79: osg::Quat::makeRotate(double, double, double, double) (in /MIL/SCTT/DEV/RTS/tmp/psturm/update/libosg.so.130)
==24954==    by 0x4983F4A: osg::Quat::makeRotate(double, osg::Vec3d const&) (in /MIL/SCTT/DEV/RTS/tmp/psturm/update/libosg.so.130)
==24954==    by 0x4572498: osgSim::DirectionalSector::computeMatrix() (in /MIL/SCTT/DEV/RTS/tmp/psturm/update/libosgSim.so.130)
==24954==    by 0x45725D0: osgSim::DirectionalSector::setDirection(osg::Vec3f const&) (in /MIL/SCTT/DEV/RTS/tmp/psturm/update/libosgSim.so.130)
==24954==    by 0x457264E: osgSim::DirectionalSector::DirectionalSector(osg::Vec3f const&, float, float, float, float) (in /MIL/SCTT/DEV/RTS/tmp/psturm/update/libosgSim.so.130)
==24954==    by 0x41FA64F: LightPoint::addVertex(flt::Vertex&) (LightPointRecords.cpp:137)
==24954==    by 0x41FC100: flt::VertexCN::readRecord(flt::RecordInputStream&, flt::Document&) (VertexRecords.cpp:114)
==24954==    by 0x421885E: flt::RecordInputStream::readRecordBody(int, int, flt::Document&) (RecordInputStream.cpp:75)
==24954==    by 0x4218ADD: flt::RecordInputStream::readRecord(flt::Document&) (RecordInputStream.cpp:40)
==24954==    by 0x4211491: flt::VertexListRecord::readRecord(flt::RecordInputStream&, flt::Document&) (GeometryRecords.cpp:596)
==24954==    by 0x421885E: flt::RecordInputStream::readRecordBody(int, int, flt::Document&) (RecordInputStream.cpp:75)
==24954==  Uninitialised value was created by a heap allocation
==24954==    at 0x402A6CC: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-x86-linux.so)
==24954==    by 0x4276E72: operator new(unsigned int) (new_op.cc:52)
==24954==    by 0x41FA5DE: LightPoint::addVertex(flt::Vertex&) (LightPointRecords.cpp:137)
==24954==    by 0x41FC100: flt::VertexCN::readRecord(flt::RecordInputStream&, flt::Document&) (VertexRecords.cpp:114)
==24954==    by 0x421885E: flt::RecordInputStream::readRecordBody(int, int, flt::Document&) (RecordInputStream.cpp:75)
==24954==    by 0x4218ADD: flt::RecordInputStream::readRecord(flt::Document&) (RecordInputStream.cpp:40)
==24954==    by 0x4211491: flt::VertexListRecord::readRecord(flt::RecordInputStream&, flt::Document&) (GeometryRecords.cpp:596)
==24954==    by 0x421885E: flt::RecordInputStream::readRecordBody(int, int, flt::Document&) (RecordInputStream.cpp:75)
==24954==    by 0x42049FA: FLTReaderWriter::readNode(std::istream&, osgDB::Options const*) const (ReaderWriterFLT.cpp:401)
==24954==    by 0x420695C: FLTReaderWriter::readNode(std::string const&, osgDB::Options const*) const (ReaderWriterFLT.cpp:194)
==24954==    by 0x44B1B81: osgDB::Registry::ReadNodeFunctor::doRead(osgDB::ReaderWriter&) const (in /MIL/SCTT/DEV/RTS/tmp/psturm/update/libosgDB.so.130)
==24954==    by 0x44A95AE: osgDB::Registry::read(osgDB::Registry::ReadFunctor const&) (in /MIL/SCTT/DEV/RTS/tmp/psturm/update/libosgDB.so.130)
 
I believe, the message is created by
 
src/osgSim/Sector.cpp lines 220-247/363
 
The member _rollAngle is not intitialized then computeMatrix() is called after first call of
 
DirectionalSector::DirectionalSector(const osg::Vec3& direction,float horizLobeAngle, float vertLobeAngle, float lobeRollAngle, float fadeAngle)
 
The issue may be fixed, if _rollAngle is initialized with lobeRollAngle in the constructor first.
 
DirectionalSector::DirectionalSector(const osg::Vec3& direction,float horizLobeAngle, float vertLobeAngle, float lobeRollAngle, float fadeAngle):
            Sector()
{
    setDirection(direction);
    setHorizLobeAngle(horizLobeAngle);
    setVertLobeAngle(vertLobeAngle);
    setLobeRollAngle(lobeRollAngle);
    setFadeAngle(fadeAngle);
}
 
void DirectionalSector::computeMatrix()
{
  double heading = atan2(_direction[0], _direction[1]);
  double pitch   = atan2(_direction[2], sqrt(_direction[0]*_direction[0] + _direction[1]*_direction[1]));
  double roll    = _rollAngle;
 
  _local_to_LP.setRotate(osg::Quat(heading,osg::Vec3d(0.0, 0.0, -1.0)));
  _local_to_LP.preMultRotate(osg::Quat(pitch, osg::Vec3d(1.0, 0.0, 0.0)));
  _local_to_LP.preMultRotate(osg::Quat(roll, osg::Vec3d(0.0, 1.0, 0.0)));
}
 
 
void DirectionalSector::setDirection(const osg::Vec3& direction)
{
   _direction = direction ;
   computeMatrix() ;
}
[…]
 
void DirectionalSector::setLobeRollAngle(float angle)
{
    _rollAngle = angle ;
    computeMatrix() ;
}
 
 

 
 
 
Mit freundlichen Grüßen / Yours sincerely
 
Peter Sturm
 
 
 


Rheinmetall Defence Electronics GmbH
Brüggeweg 54
28309 Bremen / Germany
Sitz der Gesellschaft : Bremen
Amtsgericht Bremen HRB 9659
Geschäftsführung:
Helmut Möring
Thorsten Quade
Ulrich Sasse
Vorsitzender des Aufsichtsrats:
Gordon Hargreave
This email may contain confidential information. If you are not the intended addressee, or if the information provided in this email (including any attachments) is evidently not destined for you, kindly inform us promptly and delete the message received in error (including any attachments) by erasing it from all your computers and other storage devices or media and destroying any hard copies thereof. Any unauthorized processing, forwarding, disclosure, distribution, divulgation, storage, printout or other use of this message or its attachment is prohibited. If your system is infected or otherwise bugged by any virus that is carried by this email, we disclaim any liability whatsoever for the ensuing loss or damage unless caused by our intention or gross negligence.
 


_______________________________________________
osg-submissions mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org



------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Sturm, Peter
Guest





PostPosted: Thu Jan 05, 2017 9:49 am    Post subject:
Valgrind osg 3.4.0
Reply with quote

Hi Robert,

the issue was fixed. No valgrind messages on un-init values anymore.

Thank you very much.

Regards, Peter.


Von: osg-submissions [mailto:] Im Auftrag von Robert Osfield
Gesendet: Mittwoch, 4. Januar 2017 14:04
An: OpenSceneGraph Submissions
Betreff: Re: Valgrind osg 3.4.0



Hi Peter,

Thanks for clear pointers to the cause of the uninitializaed variable usage - essentially computeMatrix() gets called prematurely. I have restructured the problem constructor to ensure that the computeMatrix() only gets called after the variables have been initialized.

The fix is now checked into git master, 3.4 and 3.2 branches:

https://github.com/openscenegraph/OpenSceneGraph/commit/b5c4f461bc8a2ad86cb55ce9a01b5baf60c200b7

Could you test this and let me know how you get on,

Robert.


On 4 January 2017 at 08:12, Sturm, Peter < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Hello,

I have found following using valgrind:

==24954== Conditional jump or move depends on uninitialised value(s)
==24954== at 0x4B7A4E9: cos (in /lib/libm-2.19.so)
==24954== by 0x4983E79: osg::Quat::makeRotate(double, double, double, double) (in /MIL/SCTT/DEV/RTS/tmp/psturm/update/libosg.so.130)
==24954== by 0x4983F4A: osg::Quat::makeRotate(double, osg::Vec3d const&) (in /MIL/SCTT/DEV/RTS/tmp/psturm/update/libosg.so.130)
==24954== by 0x4572498: osgSim::DirectionalSector::computeMatrix() (in /MIL/SCTT/DEV/RTS/tmp/psturm/update/libosgSim.so.130)
==24954== by 0x45725D0: osgSim::DirectionalSector::setDirection(osg::Vec3f const&) (in /MIL/SCTT/DEV/RTS/tmp/psturm/update/libosgSim.so.130)
==24954== by 0x457264E: osgSim::DirectionalSector::DirectionalSector(osg::Vec3f const&, float, float, float, float) (in /MIL/SCTT/DEV/RTS/tmp/psturm/update/libosgSim.so.130)
==24954== by 0x41FA64F: LightPoint::addVertex(flt::Vertex&) (LightPointRecords.cpp:137)
==24954== by 0x41FC100: flt::VertexCN::readRecord(flt::RecordInputStream&, flt::Document&) (VertexRecords.cpp:114)
==24954== by 0x421885E: flt::RecordInputStream::readRecordBody(int, int, flt::Document&) (RecordInputStream.cpp:75)
==24954== by 0x4218ADD: flt::RecordInputStream::readRecord(flt::Document&) (RecordInputStream.cpp:40)
==24954== by 0x4211491: flt::VertexListRecord::readRecord(flt::RecordInputStream&, flt::Document&) (GeometryRecords.cpp:596)
==24954== by 0x421885E: flt::RecordInputStream::readRecordBody(int, int, flt::Document&) (RecordInputStream.cpp:75)
==24954== Uninitialised value was created by a heap allocation
==24954== at 0x402A6CC: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-x86-linux.so)
==24954== by 0x4276E72: operator new(unsigned int) (new_op.cc:52)
==24954== by 0x41FA5DE: LightPoint::addVertex(flt::Vertex&) (LightPointRecords.cpp:137)
==24954== by 0x41FC100: flt::VertexCN::readRecord(flt::RecordInputStream&, flt::Document&) (VertexRecords.cpp:114)
==24954== by 0x421885E: flt::RecordInputStream::readRecordBody(int, int, flt::Document&) (RecordInputStream.cpp:75)
==24954== by 0x4218ADD: flt::RecordInputStream::readRecord(flt::Document&) (RecordInputStream.cpp:40)
==24954== by 0x4211491: flt::VertexListRecord::readRecord(flt::RecordInputStream&, flt::Document&) (GeometryRecords.cpp:596)
==24954== by 0x421885E: flt::RecordInputStream::readRecordBody(int, int, flt::Document&) (RecordInputStream.cpp:75)
==24954== by 0x42049FA: FLTReaderWriter::readNode(std::istream&, osgDB::Options const*) const (ReaderWriterFLT.cpp:401)
==24954== by 0x420695C: FLTReaderWriter::readNode(std::string const&, osgDB::Options const*) const (ReaderWriterFLT.cpp:194)
==24954== by 0x44B1B81: osgDB::Registry::ReadNodeFunctor::doRead(osgDB::ReaderWriter&) const (in /MIL/SCTT/DEV/RTS/tmp/psturm/update/libosgDB.so.130)
==24954== by 0x44A95AE: osgDB::Registry::read(osgDB::Registry::ReadFunctor const&) (in /MIL/SCTT/DEV/RTS/tmp/psturm/update/libosgDB.so.130)

I believe, the message is created by

src/osgSim/Sector.cpp lines 220-247/363

The member _rollAngle is not intitialized then computeMatrix() is called after first call of

DirectionalSector::DirectionalSector(const osg::Vec3& direction,float horizLobeAngle, float vertLobeAngle, float lobeRollAngle, float fadeAngle)

The issue may be fixed, if _rollAngle is initialized with lobeRollAngle in the constructor first.

DirectionalSector::DirectionalSector(const osg::Vec3& direction,float horizLobeAngle, float vertLobeAngle, float lobeRollAngle, float fadeAngle):
Sector()
{
setDirection(direction);
setHorizLobeAngle(horizLobeAngle);
setVertLobeAngle(vertLobeAngle);
setLobeRollAngle(lobeRollAngle);
setFadeAngle(fadeAngle);
}

void DirectionalSector::computeMatrix()
{
double heading = atan2(_direction[0], _direction[1]);
double pitch = atan2(_direction[2], sqrt(_direction[0]*_direction[0] + _direction[1]*_direction[1]));
double roll = _rollAngle;

_local_to_LP.setRotate(osg::Quat(heading,osg::Vec3d(0.0, 0.0, -1.0)));
_local_to_LP.preMultRotate(osg::Quat(pitch, osg::Vec3d(1.0, 0.0, 0.0)));
_local_to_LP.preMultRotate(osg::Quat(roll, osg::Vec3d(0.0, 1.0, 0.0)));
}


void DirectionalSector::setDirection(const osg::Vec3& direction)
{
_direction = direction ;
computeMatrix() ;
}
[…]

void DirectionalSector::setLobeRollAngle(float angle)
{
_rollAngle = angle ;
computeMatrix() ;
}






Mit freundlichen Grüßen / Yours sincerely

Peter Sturm




Rheinmetall Defence Electronics GmbH
Brüggeweg 54
28309 Bremen / Germany
Sitz der Gesellschaft : Bremen
Amtsgericht Bremen HRB 9659
Geschäftsführung:
Helmut Möring
Thorsten Quade
Ulrich Sasse
Vorsitzender des Aufsichtsrats:
Gordon Hargreave
This email may contain confidential information. If you are not the intended addressee, or if the information provided in this email (including any attachments) is evidently not destined for you, kindly inform us promptly and delete the message received in error (including any attachments) by erasing it from all your computers and other storage devices or media and destroying any hard copies thereof. Any unauthorized processing, forwarding, disclosure, distribution, divulgation, storage, printout or other use of this message or its attachment is prohibited. If your system is infected or otherwise bugged by any virus that is carried by this email, we disclaim any liability whatsoever for the ensuing loss or damage unless caused by our intention or gross negligence.




_______________________________________________
osg-submissions mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org






Rheinmetall Defence Electronics GmbH
Brüggeweg 54
28309 Bremen / Germany
Sitz der Gesellschaft : Bremen
Amtsgericht Bremen HRB 9659
Geschäftsführung:
Helmut Möring
Thorsten Quade
Ulrich Sasse
Vorsitzender des Aufsichtsrats:
Gordon Hargreave
This email may contain confidential information. If you are not the intended addressee, or if the information provided in this email (including any attachments) is evidently not destined for you, kindly inform us promptly and delete the message received in error (including any attachments) by erasing it from all your computers and other storage devices or media and destroying any hard copies thereof. Any unauthorized processing, forwarding, disclosure, distribution, divulgation, storage, printout or other use of this message or its attachment is prohibited. If your system is infected or otherwise bugged by any virus that is carried by this email, we disclaim any liability whatsoever for the ensuing loss or damage unless caused by our intention or gross negligence.

------------------
Post generated by Mail2Forum
Back to top
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> Submission All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts First Steps in Valgrind: Problems in ... zonk General 4 Sat Jul 31, 2010 6:13 am View latest post
No new posts valgrind, memory leak debugging musla General 3 Sun May 02, 2010 6:07 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP