[gdal-dev] How to correctly initialize GDAL library in a multithreaded environment?

Константин Шпурик kostia.shpuryk at gmail.com
Mon Jan 14 04:13:14 PST 2019


Oops, I've misread the mail, I thought it is already posted.(was confused
with this one.. https://github.com/OSGeo/gdal/issues/1108)

Yeah, I'll create the ticket with details.

Regards,
KS.


On Mon, Jan 14, 2019 at 2:04 PM Even Rouault <even.rouault at spatialys.com>
wrote:

> On lundi 14 janvier 2019 13:57:45 CET Константин Шпурик wrote:
> > Thank you for the quick answer!
> >
> > The version of GDAL is 2.2.3 and OS is Windows.
> >
> > I'm using not the latest version, but I've checked the latest code and it
> > seems like it will still reproduce for Windows for 2.5.0.
> >
> > Yeah, I've found the ticket,
>
> which one ?
>
> > so I'll wait until fixed and will try to
> > update to latest version.
> >
> > Thanks,
> > KS.
> >
> > On Mon, Jan 14, 2019 at 1:16 PM Even Rouault <even.rouault at spatialys.com
> >
> >
> > wrote:
> > > Hi,
> > >
> > > > I have a multithreaded application that uses GDAL. Generally it works
> > >
> > > fine,
> > >
> > > > but sometimes I have a hang when trying to create transformations
> from
> > > > different threads.
> > > >
> > > > Seems like race condition occures when initializing static CPLMutex
> > > > *hConfigMutex located in gdal\port\cpl_conv.cpp file;
> > >
> > > On which operating system and with which GDAL version ?
> > > With recent enough GDAL versions, and on Linux/Unix, I believe that
> mutex
> > > creation should now be thread-safe. But there might still be issues on
> > > Windows. We should be able to fix that more easily with C++11 mutex
> now.
> > >
> > > Please file a ticket about that on
> > > https://github.com/OSGeo/gdal/issues with the above requested details.
> > >
> > > > I was able to fix the issue by calling a function that initializes
> the
> > >
> > > mutex
> > >
> > > > before calls from different threads(just calling the following code:
> > > > CPLGetConfigOption("GDAL_DATA", nullptr);) but it doesn't feel right.
> > >
> > > Calling a function like GDALRegisterAll() that involves mutex creation
> > > before
> > > creating any thread has been the historical recommandation
> > >
> > > Even
> > >
> > > --
> > > Spatialys - Geospatial professional services
> > > http://www.spatialys.com
>
>
> --
> Spatialys - Geospatial professional services
> http://www.spatialys.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20190114/bb699dc2/attachment-0001.html>


More information about the gdal-dev mailing list