Merge pull request #2716 from mapnik/fix-gdal-atexit-crash

Prevent potential for crashes at exit related to libgdal
This commit is contained in:
Dane Springmeyer 2015-02-23 15:00:58 -08:00
commit 81a3be6e6f

View file

@ -80,7 +80,21 @@ PluginInfo::~PluginInfo()
if (module_)
{
#ifdef MAPNIK_SUPPORTS_DLOPEN
if (module_->dl) dlclose(module_->dl),module_->dl=0;
/*
We do not call dlclose for plugins that link libgdal.
This is a terrible hack, but necessary to prevent crashes
at exit when gdal attempts to shutdown. The problem arises
when Mapnik is used with another library that uses thread-local
storage (like libuv). In this case GDAL also tries to cleanup thread
local storage and leaves things in a state that causes libuv to crash.
This is partially fixed by http://trac.osgeo.org/gdal/ticket/5509 but only
in the case that gdal is linked as a shared library. This workaround therefore
prevents crashes with gdal 1.11.x and gdal 2.x when using a static libgdal.
*/
if (module_->dl && name_ != "gdal" && name_ != "ogr")
{
dlclose(module_->dl),module_->dl=0;
}
#endif
delete module_;
}