[gdal-dev] OSRSetPROJSearchPaths in multithreaded application
Dirk Vanden Boer
dirk.vdb at gmail.com
Wed Jul 17 08:01:45 PDT 2019
On Wed, Jul 17, 2019 at 3:14 PM Even Rouault <even.rouault at spatialys.com> wrote:
>
> On mercredi 17 juillet 2019 14:52:55 CEST Dirk Vanden Boer wrote:
> > After migrating to gdal 3 I'm having problems performing coordinate
> > transformations in a multi-threaded application.
> >
> > My proj.db is in a nonstandard location so I call the
> > OSRSetPROJSearchPaths once on the main thread before the call to
> > GDALAllRegister()
> >
> > I can do coordinate transformations on my main thread, but on worker
> > threads I get the proj error "Cannot find proj.db".
>
> Hum, this is supposed to work. I've just enhanced the following test to check that and it works:
>
> https://github.com/OSGeo/gdal/blob/master/autotest/cpp/test_osr_set_proj_search_paths.cpp
>
> >
> > Calling OSRSetPROJSearchPaths in each worker thread does not seem to
> > work either.
>
> You don't even need that. There's logic to handle that automagically.
>
> To debug this, you could set a breakpoint to OSRGetProjTLSContext() and see if
> it calls proj_context_set_search_paths() at least once per thread.
I did some more investigation, and it seems like the threading is
indeed not the issue.
The issue seems to be that the geotiff library also creates proj
contexts and these contexts do not have
the search paths that are passed to the OSRGetProjTLSContext call.
Callstack:
bregilab.exe!osgeo::proj::io::DatabaseContext::Private::open(const
std::basic_string<char,std::char_traits<char>,std::allocator<char> > &
databasePath, projCtx_t * ctx) Line 578 C++
bregilab.exe!osgeo::proj::io::DatabaseContext::create(const
std::basic_string<char,std::char_traits<char>,std::allocator<char> > &
databasePath, const
std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char>
>,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char>
> > > & auxiliaryDatabasePaths, projCtx_t * ctx) Line 888 C++
bregilab.exe!projCppContext::projCppContext(projCtx_t * ctx, const
char * dbPath, const char * const * auxDbPaths) Line 174 C++
bregilab.exe!getDBcontext(projCtx_t * ctx) Line 118 C++
bregilab.exe!proj_create_from_database(projCtx_t * ctx, const char *
auth_name, const char * code, PJ_CATEGORY category, int
usePROJAlternativeGridNames, const char * const * options) Line 521
C++
bregilab.exe!GTIFGetPCSInfoEx(projCtx_t * ctx, int nPCSCode, char *
* ppszEPSGName, short * pnProjOp, short * pnUOMLengthCode, short *
pnGeogCS) Line 165 C
> bregilab.exe!GTIFGetPCSInfo(int nPCSCode, char * * ppszEPSGName, short * pnProjOp, short * pnUOMLengthCode, short * pnGeogCS) Line 273 C
bregilab.exe!GTIFGetOGISDefn(gtiff * hGTIF, GTIFDefn * psDefn) Line 506 C++
bregilab.exe!GTiffDataset::LookForProjection() Line 12649 C++
bregilab.exe!GTiffDataset::GetSpatialRef() Line 18067 C++
bregilab.exe!GDALPamDataset::CloneInfo(GDALDataset * poSrcDS, int
nCloneFlags) Line 963 C++
bregilab.exe!GTiffDataset::CreateCopy(const char * pszFilename,
GDALDataset * poSrcDS, int bStrict, char * * papszOptions,
int(*)(double, const char *, void *) pfnProgress, void *
pProgressData) Line 17513 C++
bregilab.exe!GDALDriver::CreateCopy(const char * pszFilename,
GDALDataset * poSrcDS, int bStrict, char * * papszOptions,
int(*)(double, const char *, void *) pfnProgress, void *
pProgressData) Line 937 C++
bregilab.exe!inf::gdal::RasterDriver::create_dataset_copy(const
inf::gdal::RasterDataSet & reference, const std::filesystem::path &
filename, gsl::span<std::basic_string<char,std::char_traits<char>,std::allocator<char>
> const ,-1> driverOptions) Line 497 C++
...
Application code stripped
More information about the gdal-dev
mailing list