[compiler-rt] [ASan][Windows] Fix false positive for zero sized rtl allocations (PR #181015)
David Justo via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 13 11:32:56 PST 2026
================
@@ -40,8 +40,8 @@ int main() {
if (!ptr2)
return 1;
size_t heapsize = HeapSize(GetProcessHeap(), 0, ptr2);
- if (heapsize != 1) { // will be 0 without ASAN turned on
- std::cerr << "HeapAlloc size failure! " << heapsize << " != 1\n";
+ if (heapsize != 0) {
+ std::cerr << "HeapAlloc size failure! " << heapsize << " != 0\n";
----------------
davidmrdavid wrote:
nit - in the preceding comment (lines ~22->~33), there's a bunch of preamble about how we now change zero-sized allocations to 1.
As a result, this changed check can appear surprising if we don't leave a comment saying that `HeapSize` will retrieve that user-provided size, not the internal 1-sized allocation.
So I recommend we add a comment :-)
```suggestion
// `HeapSize` will retrieve the user-defined size, not the _actual_ ASan-allocated size of '1'
if (heapsize != 0) {
std::cerr << "HeapAlloc size failure! " << heapsize << " != 0\n";
```
https://github.com/llvm/llvm-project/pull/181015
More information about the llvm-commits
mailing list