[clang] [analyzer][StackAddrEscapeChecker] Fix assert failure for alloca regions (PR #109655)
Arseniy Zaostrovnykh via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 23 06:49:41 PDT 2024
necto wrote:
> Please mark the line in the test with `no-crash` where previously crashed.
Done in b2ed9f9
> Speaking of the fix, I think anything is better than a crash, but I wonder if we could do more. To me, once an alloca region goes out of scope, that should behave just as if a regular stack variable, and raise an issue. What is it not the case here?
In this case, it is not an `alloca` region that went out of scope but a regular stack variable. However, unlike other test cases, it is an `alloca` region that kept the pointer to the expired stack variable.
Just like with regions from `malloc`, `alloca` regions are harder to name. I could imagine naming them after the source location, which works for both `malloc` and `alloca`, but that requires substantially more engineering and quality control than this fix. Moreover, the use of explicit memory management primitives such as `malloc` and, even more so, `alloca` signals to me that the code likely does something non-trivial with memory, so CSA is prone to false positives because it is not tuned to this case.
https://github.com/llvm/llvm-project/pull/109655
More information about the cfe-commits
mailing list