[gdal-dev] Thread safety of GDAL projection machinery?
Even Rouault
even.rouault at mines-paris.org
Wed May 27 15:49:45 EDT 2009
Charles,
At first sight, you're likely doing things the right way and probably
discovered a bug related to multi-threading in GDAL. The use of
GDALCreateGenImgProjTransformer() should be thread-safe (provided that you
don't use the same dataset in the different threads)
By reviewing the code of 2 files that are used in the retrieving and parsing
of the csv files, there are a few variables that are supposed to be
thread-local (CPL_THREADLOCAL), but this is currently a no-op.
But as it's just a guess and maybe not the real cause for your problems,
ideally, you could file a bug in the GDAL Trac with a small program that
reproduces your issue, so that it can be investigated further.
Best regards,
Even
Le Wednesday 27 May 2009 20:41:57 Charles Karney, vous avez écrit :
> I have a multi-threaded application with reads the geodata out of many
> files using GDAL.
>
> For each image, it calls
>
> GDALCreateGenImgProjTransformer(// Source
> dataset,GDALGetProjectionRef(dataset),
> // Dest (NULL means dest is geo)
> NULL, WGS84.c_str(),
> // Don't use GCPs
> 0, 0, 0 );
>
> and I then compute the lat/long of the 4 image corners.
>
> I call
>
> GDALAllRegister();
>
> before entering the multi-threaded portion of the code.
>
> With files that require that pcs.csv be read, I get the following error
> messages
>
> ERROR 3: Read of file c:/Program Files (x86)/FWTools2.2.8/data/pcs.csv
> failed. ERROR 3: Read of file c:/Program Files
> (x86)/FWTools2.2.8/data/pcs.csv failed. ERROR 2: CPLRealloc(): Out of
> memory allocating 1956 bytes.
> ERROR 3: Read of file c:/Program Files (x86)/FWTools2.2.8/data/pcs.csv
> failed. ERROR 3: Read of file c:/Program Files
> (x86)/FWTools2.2.8/data/pcs.csv failed. ERROR 3: Read of file c:/Program
> Files (x86)/FWTools2.2.8/data/pcs.csv failed. ERROR 3: Read of file
> c:/Program Files (x86)/FWTools2.2.8/data/pcs.csv failed. ERROR 3: Read of
> file c:/Program Files (x86)/FWTools2.2.8/data/datum.csv failed. ERROR 3:
> Read of file c:/Program Files (x86)/FWTools2.2.8/data/ellipsoid.csv failed.
> ERROR 2: CPLRealloc(): Out of memory allocating 409 bytes.
> ERROR 1: No PROJ.4 translation for source SRS, coordinate
> transformation initialization has failed.
>
> This is with 6 threads. The error messages change from invocation to
> invocation as is typical with multi-threading bugs.
>
> If I change the code so that one a single thread is handling the GDAL
> stuff, everything works OK.
>
> * Is this "supposed" to work?
>
> * Do I need to do something outside the threaded portion of the code to
> initialize the projection machinery?
>
> * If it's known not to work, what GDAL calls do I need to protect with
> locks?
>
> Thanks for the help!
More information about the gdal-dev
mailing list