Skip to content

Commit

Permalink
GTiff multithreaded reading/writing: fix a deadlock situation
Browse files Browse the repository at this point in the history
Fix a deadlock encountered with
gdalwarp test1.tif test2.tif -co  COMPRESS=LZW   -co TILED=YES  -co BLOCKXSIZE=256  -co  BLOCKYSIZE=256   -co   BIGTIFF=YES  -multi  -co  NUM_THREADS=ALL_CPUS out.tif -overwrite
on the test datasets provided in OSGeo#8470 (comment)
  • Loading branch information
rouault committed Oct 13, 2023
1 parent 2cfeb1a commit d083af1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions frmts/gtiff/gtiffdataset_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,8 +560,16 @@ static void CPL_STDCALL ThreadDecompressionFuncErrorHandler(
psJob->nXBlock, psJob->nYBlock);
if (apoBlocks[i] == nullptr)
{
// Temporary disabling of dirty block fushing, otherwise
// we can be in a deadlock situation, where the
// GTiffDataset::SubmitCompressionJob() method waits for jobs
// to be finished, that can't finish (actually be started)
// because this task and its siblings are taking all the
// available workers allowed by the global thread pool.
GDALRasterBlock::EnterDisableDirtyBlockFlush();
apoBlocks[i] = poDS->GetRasterBand(iBand)->GetLockedBlockRef(
psJob->nXBlock, psJob->nYBlock, TRUE);
GDALRasterBlock::LeaveDisableDirtyBlockFlush();
if (apoBlocks[i] == nullptr)
return false;
}
Expand Down

0 comments on commit d083af1

Please sign in to comment.