[clang] [Thread Analysis] Fix a bug in context update in alias-analysis (PR #178952)
Marco Elver via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 31 05:47:48 PST 2026
melver wrote:
I tried to test this on Linux -next (which is enabling -Wthread-safety): https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/
But when applying this patch I get tons of false positives:
```
CC lib/test_context-analysis.o
lib/test_context-analysis.c:84:1: error: releasing raw_spinlock '__UNIQUE_ID_unlock_245' that was not held [-Werror,-Wthread-safety-analysis]
84 | TEST_SPINLOCK_COMMON(raw_spinlock,
| ^
lib/test_context-analysis.c:76:5: note: expanded from macro 'TEST_SPINLOCK_COMMON'
76 | { guard(class)(&d->lock); op(d->counter); } \
| ^
./include/linux/cleanup.h:419:2: note: expanded from macro 'guard'
419 | CLASS(_name, __UNIQUE_ID(guard))
| ^
./include/linux/cleanup.h:300:3: note: expanded from macro 'CLASS'
300 | class_##_name##_constructor
| ^
note: (skipping 4 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
././include/linux/compiler_types.h:16:23: note: expanded from macro '__PASTE'
16 | #define __PASTE(a, b) ___PASTE(a, b)
| ^
././include/linux/compiler_types.h:15:24: note: expanded from macro '___PASTE'
15 | #define ___PASTE(a, b) a##b
| ^
<scratch space>:29:1: note: expanded from here
29 | __UNIQUE_ID_unlock_245
| ^
lib/test_context-analysis.c:84:1: error: acquiring raw_spinlock 'd->lock' that is already held [-Werror,-Wthread-safety-analysis]
lib/test_context-analysis.c:77:5: note: expanded from macro 'TEST_SPINLOCK_COMMON'
77 | { guard(class##_irq)(&d->lock); op(d->counter); } \
| ^
./include/linux/cleanup.h:419:2: note: expanded from macro 'guard'
419 | CLASS(_name, __UNIQUE_ID(guard))
| ^
./include/linux/cleanup.h:300:3: note: expanded from macro 'CLASS'
300 | class_##_name##_constructor
| ^
```
I haven't been able to isolate a minimal reproducer yet that we can use as a test case.
https://github.com/llvm/llvm-project/pull/178952
More information about the cfe-commits
mailing list