<div dir="ltr"><div dir="ltr"><div>I just refactored our GDAL init code which required me to add calls to the init function to the <b>main()</b> of several of our unit test executables. Now they all fail our TSAN tests with the following:</div><div><br></div><div><pre id="m_6244918996173229523gmail-out" style="box-sizing:inherit;background-color:rgba(0,0,0,0.05);border-radius:10px;color:rgb(20,20,31);font-family:ui-monospace,sfmono-regular,"sf mono",jetbrainsmono,consolas,monospace;line-height:1.66;margin-top:0px;margin-bottom:26px;padding:0.8rem 1rem;font-size:14px"><span style="box-sizing:inherit"><b style="box-sizing:inherit">18:46:51</b> </span>29: WARNING: ThreadSanitizer: lock-order-inversion (potential deadlock) (pid=111437)
<span style="box-sizing:inherit"><b style="box-sizing:inherit">18:46:51</b> </span>29: Cycle in lock order graph: M889273480187642592 (0x000000000000) => M889596235056216640 (0x000000000000) => M889273480187642592
<span style="box-sizing:inherit"><b style="box-sizing:inherit">18:46:51</b> </span>29:
<span style="box-sizing:inherit"><b style="box-sizing:inherit">18:46:51</b> </span>29: Mutex M889596235056216640 acquired here while holding mutex M889273480187642592 in main thread:
<span style="box-sizing:inherit"><b style="box-sizing:inherit">18:46:51</b> </span>29: #0 pthread_mutex_lock ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:4240 (libtsan.so.0+0x53908)
<span style="box-sizing:inherit"><b style="box-sizing:inherit">18:46:51</b> </span>29: #1 CPLAcquireMutex <null> (RasterTableTests+0x61da93a)
<span style="box-sizing:inherit"><b style="box-sizing:inherit">18:46:51</b> </span>29: #2 main /home/jenkins-slave/workspace/core-tsan-gcc/Tests/ee/RasterTableTests.cpp:2292 (RasterTableTests+0x34705ba)
</pre>The relevant parts of the init() function are:</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">GDALAllRegister();<br>OGRRegisterAll();<br>CPLSetErrorHandler(*gdal_error_handler);</blockquote><div><br></div><div>I found <a href="https://github.com/OSGeo/gdal/issues/1108" target="_blank">https://github.com/OSGeo/gdal/issues/1108</a> and related which seems to indicate that something was fixed perhaps in 3.9.</div><div><br></div><div>We are in the process of updating from 3.7.3 to 3.10.2 and the problem occurs in CI builds on machines which still have 3.7.3. It does not occur with the new TSAN build container which has 3.10.2.</div><div><br></div><div>Can I assume that the reworking of mutex handling in the above issue was indeed the cause of this? We can suppress the failure until we are past the GDAL update.</div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Simon Eves<div>Senior Rendering Engineer</div><div>+1 (415) 902-1996<br><a href="mailto:simon.eves@heavy.ai" target="_blank">simon.eves@heavy.ai</a></div><div><span><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(17,85,204);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"><span style="border:none;display:inline-block;overflow:hidden;width:156px;height:29px"></span></span></p></span></div></div></div></div>
</div>