[Gdal-dev] multithread problem with hfa

Frank Warmerdam fwarmerdam at gmail.com
Thu Apr 7 10:18:40 EDT 2005

On Apr 7, 2005 9:53 AM, Stephane Routelous <route at cae.com> wrote:
> Hi,
> we have a crash on windows (using gdal 1.2.5) with a multithread application
> reading 2 different IMG files in 2 different threads.
> Is gdal thread safe ?


GDAL is *not* thread safe.  You will need to protect pretty much all
GDAL access with a BigLock(tm).  

There are some relatively minor race conditions in the way error
messages are stored (one global error context).  Also a variety of
string management functions use static globals that are not 
thread local.  But the biggest issue by far is that GDAL uses a
single global raster block cache.  That means that in a multithreaded
application, working on two distinct GDALDatasets you can end up 
with one thread expiring and freeing a cache block still in use by 
another thread. 

I am interested in making GDAL threadsafe but it is a fairly substantial
effort and I can't say when I might get around to it. However, it should
be relatively easy to correct the block caching issues. 

Best regards,
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent

More information about the Gdal-dev mailing list