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 

Potential crash in ObjectCache::removeExpiredObjectsInCache


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
guyv
Appreciator


Joined: 13 Feb 2009
Posts: 102

PostPosted: Fri May 04, 2018 6:12 pm    Post subject:
Potential crash in ObjectCache::removeExpiredObjectsInCache
Reply with quote

Hi,

I think I found a bug in the following function:

void ObjectCache::removeExpiredObjectsInCache(double expiryTime)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_objectCacheMutex);

// Remove expired entries from object cache
ObjectCacheMap::iterator oitr = _objectCache.begin();
while(oitr != _objectCache.end())
{
if (oitr->second.second<=expiryTime)
{
// _objectCache.erase(oitr++); << This line was causing unpredictable issues.
oitr = _objectCache.erase(oitr); << replaced with this line.
}
else
{
++oitr;
}
}
}

Regards,

Guy Volckaert, ing.
Snr Software Engineer

Meggitt Training Systems (Quebec) Inc.
Systèmes d’entraînement Meggitt (Québec) Inc.
6140 Henri Bourassa West
Montreal, Quebec, H4R 3A6
Canada

Tel: 1 (514) 339 9938 Ext 617
Fax: 1 (514) 339 2641
Cell: 1 (514) 928-5641
email: (
Only registered users can see emails on this board!
Get registred or enter the forums!
)
url; www.meggitt.com
skype: guy.volckaert

Svp. Considérez l’environnement avant d’imprimer
Please consider the environment before printing this e-mail.




This e-mail may contain proprietary information and/or copyright material. This e-mail is intended for the use of the addressee only. Any unauthorized use may be unlawful. If you receive this e-mail by mistake, please advise the sender immediately by using the reply facility in your e-mail software.

Information contained in and/or attached to this document may be subject to export control regulations of the European Community, USA, or other countries. Each recipient of this document is responsible to ensure that usage and/or transfer of any information contained in this document complies with all relevant export control regulations. If you are in any doubt about the export control restrictions that apply to this information, please contact the sender immediately.

Be aware that Meggitt may monitor incoming and outgoing e-mails to ensure compliance with the Meggitt IT Use policy.

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12132

PostPosted: Sat May 05, 2018 6:33 am    Post subject:
Potential crash in ObjectCache::removeExpiredObjectsInCache
Reply with quote

Hi Guy,

I tried your suggestion but it doesn't compile...

/home/robert/OpenSceneGraph/src/osgDB/ObjectCache.cpp:148:18: error:
no match for ‘operator=’ (operand types are
‘std::map<std::pair<std::__cxx11::basic_string<char>,
osg::ref_ptr<const osgDB::Options> >,
std::pair<osg::ref_ptr<osg::Object>, double>,
osgDB::ObjectCache::ClassComp>::iterator {aka
std::_Rb_tree_iterator<std::pair<const
std::pair<std::__cxx11::basic_string<char>, osg::ref_ptr<const
osgDB::Options> >, std::pair<osg::ref_ptr<osg::Object>, double> > >}’
and ‘void’)
oitr = _objectCache.erase(oitr);
^
In file included from /usr/include/c++/5/map:60:0,
from /home/robert/OpenSceneGraph/include/osg/GLExtensions:24,
from /home/robert/OpenSceneGraph/include/osg/Shader:25,
from /home/robert/OpenSceneGraph/include/osg/StateAttribute:20,
from /home/robert/OpenSceneGraph/include/osg/StateSet:18,
from /home/robert/OpenSceneGraph/include/osg/Node:19,
from /home/robert/OpenSceneGraph/include/osgDB/ObjectCache:17,
from /home/robert/OpenSceneGraph/src/osgDB/ObjectCache.cpp:14:
/usr/include/c++/5/bits/stl_tree.h:174:12: note: candidate:
std::_Rb_tree_iterator<std::pair<const
std::pair<std::__cxx11::basic_string<char>, osg::ref_ptr<const
osgDB::Options> >, std::pair<osg::ref_ptr<osg::Object>, double> > >&
std::_Rb_tree_iterator<std::pair<const
std::pair<std::__cxx11::basic_string<char>, osg::ref_ptr<const
osgDB::Options> >, std::pair<osg::ref_ptr<osg::Object>, double> >
Quote:
::operator=(const std::_Rb_tree_iterator<std::pair<const
std::pair<std::__cxx11::basic_string<char>, osg::ref_ptr<const
osgDB::Options> >, std::pair<osg::ref_ptr<osg::Object>, double> > >&)
struct _Rb_tree_iterator
^
/usr/include/c++/5/bits/stl_tree.h:174:12: note: no known conversion
for argument 1 from ‘void’ to ‘const
std::_Rb_tree_iterator<std::pair<const
std::pair<std::__cxx11::basic_string<char>, osg::ref_ptr<const
osgDB::Options> >, std::pair<osg::ref_ptr<osg::Object>, double> > >&’
src/osgDB/CMakeFiles/osgDB.dir/build.make:686: recipe for target
'src/osgDB/CMakeFiles/osgDB.dir/ObjectCache.cpp.o' failed
make[2]: *** [src/osgDB/CMakeFiles/osgDB.dir/ObjectCache.cpp.o] Error 1

This is with gcc 5.4.0. What platform and compiler are you using?

Robert.


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12132

PostPosted: Sat May 05, 2018 11:50 am    Post subject:
Potential crash in ObjectCache::removeExpiredObjectsInCache
Reply with quote

Hi Guy,

I have look into the build issue and your proposed change. Your
proposed changes requires C++11, while the original code uses the
standard pre C++11 method to erasing an element of std::map<>. I
believe the original code should be fine, for it not to work then
there must be an issue with the increment operation implementation
order or operation or for all iterators to the map being invalidated
by the erase. It sounds like your compiler is tripping up on this.

The best solution I can come up with is:

#if __cplusplus > 199711L
oitr = _objectCache.erase(oitr);
#else
_objectCache.erase(oitr++);
#endif

I've checked the into the 3.6 branch and master:


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

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

Cheers,
Robert.


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General 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 osgText 3.6.3 crash Trajce Nikolov NICK General 2 Wed Sep 12, 2018 12:25 pm View latest post
No new posts Crash when using LineSegmentIntersector sbrkopac General 5 Thu Aug 02, 2018 10:03 pm View latest post
No new posts [Crash issue] no error info even set ... pwang General 1 Sun Jul 29, 2018 1:20 pm View latest post
No new posts [Crash issue] How to add&remove d... pwang General 2 Thu Jul 26, 2018 10:10 am View latest post
No new posts RayIntersector with KdTree causes a c... Ale General 15 Thu Jul 26, 2018 9:33 am 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