[clang] [Thread Analysis] Fix a bug in context update in alias-analysis (PR #178952)

Ziqing Luo via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 4 18:49:56 PST 2026


ziqingluo-90 wrote:

> The build failure on linux is relevant:
> 
> ```
>  In file included from /home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/lib/scudo/standalone/tests/primary_test.cpp:11:
>   In file included from /home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/lib/scudo/standalone/allocator_config.h:16:
>   /home/gha/actions-runner/_work/llvm-project/llvm-project/compiler-rt/lib/scudo/standalone/primary32.h:306:33: error: reading variable 'FreeListInfo' requires holding mutex 'getSizeClassInfo(I).Mutex' [-Werror,-Wthread-safety-precise]
>     306 |     for (BatchGroupT &BG : Sci->FreeListInfo.BlockList) {
> ```
> 
> Again, it is a bug that was hided by the bug this PR is fixing. A small reproducer will be like this:
> 
> ```
> void testEscapeInvalidationHappensRightAfterTheCtorCall(Foo* F) {
>   Foo* L = F;
>   MutexLock ScopeLock(&L->mu);
> 
>   struct {
>     int DataMember GUARDED_BY(F->mu);
>   } Data;
> 
>   Data.DataMember = 0;
> }
> ```
> 
> The fix will be that we need also call `updateLocalVarMapCtx(nullptr);` in `VisitCXXConstructExpr`.

I realized that if we do this way, there are too many places need to call `updateLocalVarMapCtx(nullptr)`, which is not good.  I then realized that the fix can be simpler and better:  just call `updateLocalVarMapCtx(S)` after the visit of `S`.  
@melver @aaronpuchert  please take another look.

https://github.com/llvm/llvm-project/pull/178952


More information about the cfe-commits mailing list