[llvm] [ARM] Avoid reference into modified vector (PR #93965)

Rodolfo Wottrich via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 10 07:00:37 PDT 2024


rgwott wrote:

@nikic here is a reproducer:

> void a();
> void b(int c, int d, int, void *, struct e *f) { a(2, c, d, f); }
> void g(int c, int d, int, void *, struct e *f) { a(4, c, d, f); }

`clang --target=arm -mcpu=cortex-m55 -Oz  repro.c`

I dis not see a use-after-free report in valgrind, but we do see this STL assertion:
`/usr/include/c++/11/bits/stl_vector.h:1045: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = llvm::outliner::Candidate; _Alloc = std::allocator<llvm::outliner::Candidate>; std::vector<_Tp, _Alloc>::reference = llvm::outliner::Candidate&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]: Assertion '__n < this->size()' failed.`

No rush to revert this change, as I reverted it downstream to keep on working and I can reapply it once a fix comes from downstream.
Thanks!

https://github.com/llvm/llvm-project/pull/93965


More information about the llvm-commits mailing list