[gdal-dev] Multithread deadlock

Francisco Javier Calzado francisco.javier.calzado at ericsson.com
Mon Sep 26 06:33:38 PDT 2016


Hi guys,

I am experiencing a deadlock with just 2 threads in a single reader & multiple writer scenario. This is, threads read from the same input file (using different handlers) and then write different output files. Deadlock comes when the block cache gets filled. The situation is the following:


-          T1 and T2 read datasets D1 and D2, both pointing to the same input raster (GTiff).

-          Block cache gets filled.

-          T1 tries to lock one block in the cache to write data. But cache is full, so it tries to free dirty blocks from T2 (as seen in Internalize() method). For that purpose, it requires apparently a mutex from D2.

-          However T2 is in a state where must wait for thread T1 to finish working with T2's blocks. In this state, T2 has a mutex acquired from D2.

At least, that is what it seems to be happening based on source code. Maybe I'm wrong, I don't have a full picture overview about how GDAL is internally working. The thing is that I can reproduce this issue with the following test code and dataset:
https://drive.google.com/file/d/0B-OCl1FjBi0YSkU3RUozZjc5SnM/view?usp=sharing

Oddly enough, ticket with number #6163 is supposed to fix this, but its failing in my case. I am working with GDAL 2.1.0 version under VS2015 (x32, Debug) compilation.

Even, what do you think?

Thanks!
Javier C.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20160926/6a05fd39/attachment-0001.html>


More information about the gdal-dev mailing list