[gdal-dev] Possible concurrency issue in OGRCoordinateTransformation

Even Rouault even.rouault at spatialys.com
Tue Sep 13 12:23:58 PDT 2016


Le mardi 13 septembre 2016 17:09:30, Wood, Alexander a écrit :
> Hi,
> I've encountered what appears to be a concurrency issue when calling
> OGRCoordinateTransformation::Transform from multiple threads.  What I've
> found is that when Transform is called from multiple asynchronous tasks,
> I'm getting inconsistent results given the same inputs.  This is
> pronounced with the projection used in the GINA Elevation dataset
> (Alaska); sample data can be found here:
> http://ifsar.gina.alaska.edu/data/2013/DTM/IFSAR.SDMI.2013.FUGRO.DTM_N59W1
> 44/IFSAR.SDMI.2013.FUGRO.DTM_N59W144.tar.gz
> 
> The projection used by this datasource is:
> PROJCS["NAD_1983_CORS96_Alaska_Albers",GEOGCS["GCS_NAD_1983_CORS96",DATUM["
> NAD_1983_CORS96",SPHEROID["GRS_1980",6378137,298.257222101]],PRIMEM["Greenw
> ich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Albers_Conic_Equal_A
> rea"],PARAMETER["standard_parallel_1",55],PARAMETER["standard_parallel_2",6
> 5],PARAMETER["latitude_of_center",50],PARAMETER["longitude_of_center",-154]
> ,PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["metre",1,
> AUTHORITY["EPSG","9001"]]]
> 
> Or in proj4:
> +proj=aea +lat_1=55 +lat_2=65 +lat_0=50 +lon+0-154 +x_0=0 +y_0=0
> +ellps=GRS80 + units=m +no_defs
> 
> The following code snippet reproduced the problem for me.  If I were
> comment out the async tasks and simply perform the transform
> synchronously, the outputs all remain consistent with the expected result.
>  Also make note of the CPLConfigOption "USE_PROJ_480_FEATURES".  Setting
> this to "NO" will also produce consistent results, as indicated in the
> inline comments below.
> 

Alex,

It seems that you use the same OGRCoordinateTransform* object simultaneously 
from multiple threads. This is clearly an invalid use of the API (most 
GDAL/OGR objects are not thread-safe, unless explicitly stated otherwise). You 
need to have one coordinate transform object per thread. Setting 
USE_PROJ_480_FEATURES=NO will serialize the calls but this still remains an 
invalid use of the API (that happens to work by chance).

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list