Issue 151430
Summary [TableGen] ASAN reports use-after-poison in StringInit::get, when used with BumpPtrAllocator
Labels new issue
Assignees
Reporter chanha-park
    I've encountered an use-after-poison issue, while generating header using my own `.td` file and `llvm::TableGenMain`.

The below is the reduced input.

```cpp
#include "llvm/Support/Allocator.h"
#include "llvm/TableGen/Record.h"

namespace dummy_ns {

// unused function
auto dummy_allocate(llvm::BumpPtrAllocator &allocator) {
  return allocator.Allocate(1, 16);
}

} // namespace dummy_ns

int main() {
 llvm::RecordKeeper records;

  auto foo = llvm::StringInit::get(records, "foo");
  auto bar = llvm::StringInit::get(records, "bar");
}
```

compiled with `clang++ main.cc -lLLVMTableGen -lLLVMSupport -lLLVMDemangle -fsanitize=address -fno-rtti`

The second `StringInit::get` causes use-after-poison.
Even though `dummy_allocate` is unused, the error is gone when I remove that function.
is this just false-positive?

Tested with libLLVM built in Release build, with sanitizer disabled. 

I tested it in llvmorg-20.1.4 tag && main branch.
and reproducer in compiler-explorer: https://godbolt.org/z/rhYsK983j

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to