[osg-users] Crash in ReaderWriterCURL::readFile when used with DatabasePager

Hartwig Wiesmann hartwig.wiesmann at skywind.eu
Sun Dec 17 15:46:40 PST 2017


I am using PagedLOD together with a pseudo-loader to load files via the network. To load the files the ReaderWriterCURL class is used.

The database pager is set up with one general and one HTTP thread. This means that the ReaderWriterCURL::readFile(ObjectType, const std::string&, const osgDB::ReaderWriter::Options*) (and WriteFile) method is always called from the same thread!

In ReaderWriterCURL::readFile the class method getEasyCurl() is used to get a reference to an EasyCurl object. And always the same EasyURL object is returned because it is always the same thread that is calling getEasyCurl().

The problem is (seems to be) that although the ReaderWriterCURL::readFile is used by the same thread it can happen that different instances of ReaderWriterCURL::readFile are running in parallel (verified by debug output). But this means that these instances use the SAME EasyCURL object! And this will lead to a crash.

For testing purposes I replaced the call to getEasyCurl in ReaderWriterCURL::readFile with osg::ref_ptr<EasyCurl> easyCurl and did the corresponding replacements ("." replaced by "->") and everything went smoothly.

I do not know the purpose of getEasyCur() using a map of EasyCurl objects as this method is only used in ReaderWriterCURL::readFile and writeFile. The only thing that has to be prevented is that curl_easy_init() is called in parallel. But this can also be achieved by returning an osg::ref_ptr<EasyCurl> object in combination with a lock.

Awaiting your comments!


Read this topic online here:

More information about the osg-users mailing list