<div dir="ltr">Deadlocks are usually easy to debug if you can get a traceback when deadlocked. If you can attach with gdb (or run in the debugger) and reproduce and post the stack at the time ('where' from gdb), it should be no problem to fix. Trying to reproduce on different hardware can be difficult.</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 26, 2016 at 9:33 AM, Francisco Javier Calzado <span dir="ltr"><<a href="mailto:francisco.javier.calzado@ericsson.com" target="_blank">francisco.javier.calzado@ericsson.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal">Hi guys,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">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:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p><u></u><span>-<span style="font:7.0pt "Times New Roman"">
</span></span><u></u>T1 and T2 read datasets D1 and D2, both pointing to the same input raster (GTiff).<u></u><u></u></p>
<p><u></u><span>-<span style="font:7.0pt "Times New Roman"">
</span></span><u></u>Block cache gets filled.<u></u><u></u></p>
<p><u></u><span>-<span style="font:7.0pt "Times New Roman"">
</span></span><u></u>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.<u></u><u></u></p>
<p><u></u><span>-<span style="font:7.0pt "Times New Roman"">
</span></span><u></u>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.
<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">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:<u></u><u></u></p>
<p class="MsoNormal"><a href="https://drive.google.com/file/d/0B-OCl1FjBi0YSkU3RUozZjc5SnM/view?usp=sharing" target="_blank">https://drive.google.com/file/<wbr>d/0B-<wbr>OCl1FjBi0YSkU3RUozZjc5SnM/<wbr>view?usp=sharing</a><u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">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.
<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Even, what do you think?<u></u><u></u></p>
<p class="MsoNormal"><span lang="ES-TRAD"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="ES-TRAD">Thanks!<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="ES-TRAD">Javier C.<u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
<br>______________________________<wbr>_________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="noreferrer" target="_blank">http://lists.osgeo.org/<wbr>mailman/listinfo/gdal-dev</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Andrew Bell<br><a href="mailto:andrew.bell.ia@gmail.com" target="_blank">andrew.bell.ia@gmail.com</a></div>
</div>