Opened 15 years ago

Closed 15 years ago

#3013 closed defect (fixed)

cpl_findfile.cpp and cpl_csv.cpp uses CPL_THREADLOCAL, which is a no-op

Reported by: Even Rouault Owned by: Even Rouault
Priority: normal Milestone: 1.7.0
Component: default Version: unspecified
Severity: normal Keywords:
Cc: warmedam, ckarney@…

Description

Might be related to the following issue encountered by Charles Karney :

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!

Change History (2)

comment:1 by Even Rouault, 15 years ago

Charles,

In r17143, I've replaced all uses of CPL_THREADLOCAL by CPLGetTLS()/CPLSetTLS() mechanism.

Would you mind testing if it improves things in your use case and report ? You can use daily builds done by Tamas Szekerest. They are available at http://vbkto.dyndns.org:1280/sdk/Default.aspx. Use binaries listed in the first array, from the -development branch (not the -stable one, as the fix is here in svn head trunk for the moment). The binaries with the above changes will be generated tomorrow (29/05/2009) after 19:00 CET (GMT+2).

(to answer your last email : I'm not in position to build on Windows myself)

comment:2 by Even Rouault, 15 years ago

Milestone: 1.7.0
Resolution: fixed
Status: newclosed

What was announced in the ticket title was implemented. Charles Karney's issue might be due to something else. Closing

Note: See TracTickets for help on using tickets.