<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/87324>87324</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
CHECK failed: "((tctx->status)) == ((ThreadStatusInvalid))"
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
landell-xperi
</td>
</tr>
</table>
<pre>
Clang version: 18.0.0
The following assertion is hit when using asan:
```
AddressSanitizer: CHECK failed: sanitizer_thread_registry.cpp:161 "((tctx->status)) == ((ThreadStatusInvalid))" (0xae0ee3a0, 0x0) (tid=2095999)
```
The value of the `tctx->status` field does not have any of the values in the related enum. Looks like a race condition since the the status value passes the assertion just after the creation of the object but has changed when the assertion is actually triggered. The `QuarantinePop` function returns `nullptr` in this scenario. I have seen other but similar assertion failures (value is not in the enum range) in other parts of the related code but this is the most common that I can trigger.
Suspicion goes to the following commit: https://reviews.llvm.org/D158786
Looks like there was a local allocator used together with a local mutex. Then the allocator was changed to a global one while the same mutex is still used. I have reverted back to using the local allocator in the `GetAsanThreadContext` function and can no longer reproduce the issue.
I have not been able to create a minimal test case for this. It reproduces in a chromium derivative but I can't share the code unfortunately.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVM2O4zYTfBr60hiBovwjH3yYb7z-MkgOCXbvi5bYlrhDkQbZtD15-oCUPX_IMYBtQSa7WF1VbIzRDI5oJ1b_E6v9AhOPPuwsOk3WPlxPFMyi8_p192TRDXCmEI13onmEuq1kJYXcC_k4__4YCY7eWn8xbgCMkQIb78BEGA3DZSQHKc5rmDFuxWt5-5TXR60DxfgdnWHzN4V81tNv355-hyMaSzq_x_viTx4Dof4ZaDCRw2vVn06ieazXNQilhGqFarnn64NovkVGTlGorVBbEM1eNHuYd_woIN_L-rM7ozV63iaUylvkFUkSNSiFegJ5lQVBtWy0aPZKblfbbdn-b_1kVc5o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