<div style="font-family:Microsoft YaHei;font-size:14px;color:#000000;" class="l_node_has_color"><p data-start="153" data-end="160">Hi all,</p>
<p data-start="162" data-end="308">I've opened <a href="https://gitlab.isc.org/isc-projects/kea/-/issues/4164" target="_new" rel="noopener" data-start="174" data-end="242">issue #4164</a> to report a potential concurrency issue in the <em data-start="290" data-end="302">ping-check</em> hook.</p>
<p data-start="310" data-end="553">During testing, I observed that <code data-start="342" data-end="356">finishFree()</code> can be called concurrently for the same context from different threads. The following log snippet shows two threads entering <code data-start="482" data-end="496">finishFree()</code> for the same target (<code data-start="518" data-end="529">3.3.3.253</code>) almost simultaneously:</p>
<div>
<div dir="ltr">```</div>
</div>
<div dir="ltr">2025-10-09 16:01:42.843 DEBUG [kea-dhcp4.ping-check-hooks/14428.140236733867776] PML_DEBUG: ENTER finishFree for context 0x7f8b44041230, target 3.3.3.253, thread 140236733867776<br>2025-10-09 16:01:42.843 DEBUG [kea-dhcp4.ping-check-hooks/14428.140236725475072] PML_DEBUG: ENTER finishFree for context 0x7f8b60045a80, target 3.3.3.253, thread 140236725475072<br>2025-10-09 16:01:42.843 DEBUG [kea-dhcp4.ping-check-hooks/14428.140236733867776] PML_DEBUG: EXIT finishFree for context 0x7f8b44041230, target 3.3.3.253, thread 140236733867776</div>
<div dir="ltr">```</div>
<p data-start="1097" data-end="1234">This supports the hypothesis that two threads can free or modify the same ping context concurrently, leading to segmentation fault in <code data-start="197" data-end="225">PingCheckMgr::finishFree()</code> .</p>
<p data-start="1236" data-end="1304">In the issue, I've proposed two possible directions for fixing this:</p>
<ol data-start="1305" data-end="1515">
<li data-start="1305" data-end="1388">
<p data-start="1308" data-end="1388">Add <strong data-start="1312" data-end="1337">idempotent protection</strong> around <code data-start="1345" data-end="1359">finishFree()</code> and related operations; or</p>
</li>
<li data-start="1389" data-end="1515">
<p data-start="1392" data-end="1515">Refactor <code data-start="1401" data-end="1416">setArgument()</code> / <code data-start="1419" data-end="1429">unpark()</code> calls to be posted as tasks via <code data-start="1462" data-end="1483">io_service_->post()</code>, ensuring serialized execution.</p>
</li>
</ol>
<p data-start="1517" data-end="1614">I'd appreciate any feedback on which approach might be more aligned with Kea's design principles.</p>
<p data-start="1616" data-end="1647">Best regards.</p>
<p> </p>
<p style="color: #000; font-size: 16px;">---</p>
<div id="cs2c_mail_sigature" style="color: #000; font-size: 16px; font-family: Microsoft YaHei;"></div>
<p> </p></div>