| Issue |
237868
|
| Summary |
[ASan] findStoresToUninstrumentedArgAllocas moves an argument store above an earlier store to the same alloca
|
| Labels |
compiler-rt:asan,
miscompilation,
generated by fuzzer
|
| Assignees |
|
| Reporter |
ChoKyuWon
|
### reproducer
godbolt: https://godbolt.org/z/6EjccKs9T
```llvm
define void @sink(ptr %p) {
ret void
}
define i32 @f(i32 %x) sanitize_address {
%buf = alloca [4 x i32], align 4
%a = alloca i32, align 4
store i32 5, ptr %a, align 4
store i32 %x, ptr %a, align 4
call void @sink(ptr %buf)
%v = load i32, ptr %a, align 4
ret i32 %v
}
define i32 @main() {
%v = call i32 @f(i32 3)
ret i32 %v
}
```
```console
$ opt -S -passes=asan issue-repro.ll
...
define i32 @f(i32 %x) #0 {
%a = alloca i32, align 4
store i32 %x, ptr %a, align 4
%asan_local_stack_base = alloca i64, align 8
...
store i32 5, ptr %a, align 4
call void @sink(ptr %12)
%v = load i32, ptr %a, align 4
...
ret i32 %v
}
...
```
### suggested fix
`findStoresToUninstrumentedArgAllocas` skips (`continue`) a store into an uninstrumented alloca whose value is not an argument, but still collects a later argument store into the same alloca.
`processStaticAllocas` then moves that store before `InsBefore`, above the skipped one, so the two stores to `%a` swap and the load reads 5.
Treat a skipped store as a barrier for its destination: remember the underlying objects of skipped stores and do not collect an argument store into one of them.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs