[clang] [clang-tools-extra] [libcxx] [clang] Enable sized deallocation by default in C++14 onwards (PR #83774)

Vitaly Buka via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 26 11:16:28 PDT 2024


vitalybuka wrote:

This is causing new/delete mismatch https://lab.llvm.org/buildbot/#/builders/168/builds/20063

```
=================================================================
==2164144==ERROR: AddressSanitizer: new-delete-type-mismatch on 0x5030000035b0 in thread T0:
  object passed to delete has wrong type:
  size of the allocated type:   25 bytes;
  size of the deallocated type: 24 bytes.
    #0 0x555c21886d82 in operator delete(void*, unsigned long) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp:155:3
    #1 0x555c21a2d47c in __libcpp_operator_delete<void *, unsigned long> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/new:279:3
    #2 0x555c21a2d47c in __do_deallocate_handle_size<> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/new:303:10
    #3 0x555c21a2d47c in __libcpp_deallocate /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/new:316:12
    #4 0x555c21a2d47c in deallocate /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__memory/allocator.h:133:7
    #5 0x555c21a2d47c in deallocate /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__memory/allocator_traits.h:312:9
    #6 0x555c21a2d47c in ~basic_string /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/string:1126:7
    #7 0x555c21a2d47c in llvm::TGParser::addDefOne(std::__1::unique_ptr<llvm::Record, std::__1::default_delete<llvm::Record>>) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/TableGen/TGParser.cpp:545:22
    #8 0x555c21a2bc41 in llvm::TGParser::addEntry(llvm::RecordsEntry) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/TableGen/TGParser.cpp:416:10
    #9 0x555c21a5948e in llvm::TGParser::ParseDef(llvm::MultiClass*) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/TableGen/TGParser.cpp:3625:10
    #10 0x555c21a5ccab in llvm::TGParser::ParseObject(llvm::MultiClass*) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/TableGen/TGParser.cpp:4325:31
    #11 0x555c21a651f1 in ParseObjectList /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/TableGen/TGParser.cpp:4356:9
    #12 0x555c21a651f1 in llvm::TGParser::ParseFile() /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/TableGen/TGParser.cpp:4365:7
    #13 0x555c219ba36f in llvm::TableGenMain(char const*, std::__1::function<bool (llvm::raw_ostream&, llvm::RecordKeeper&)>) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/TableGen/Main.cpp:125:14
    #14 0x555c218986c5 in main /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/TableGen/TableGen.cpp:84:10
    #15 0x7f0373e2814f  (/lib/x86_64-linux-gnu/libc.so.6+0x2814f) (BuildId: 6a981b07a3731293c24c10a21397416d3c3d52ed)
    #16 0x7f0373e28208 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x28208) (BuildId: 6a981b07a3731293c24c10a21397416d3c3d52ed)
    #17 0x555c217b2cb4 in _start (/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/llvm-min-tblgen+0x134cb4)
0x5030000035b0 is located 0 bytes inside of 25-byte region [0x5030000035b0,0x5030000035c9)
allocated by thread T0 here:
    #0 0x555c2188611d in operator new(unsigned long) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp:86:3
    #1 0x555c219f9c45 in __libcpp_operator_new<unsigned long> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/new:270:10
    #2 0x555c219f9c45 in __libcpp_allocate /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/new:294:10
    #3 0x555c219f9c45 in allocate /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__memory/allocator.h:119:32
    #4 0x555c219f9c45 in __allocate_at_least<std::__1::allocator<char> > /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__memory/allocate_at_least.h:41:19
    #5 0x555c219f9c45 in __init /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/string:2228:25
    #6 0x555c219f9c45 in basic_string<llvm::StringRef, 0> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/string:1071:5
    #7 0x555c219f9c45 in llvm::StringInit::getAsUnquotedString() const /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/TableGen/Record.h:736:12
    #8 0x555c21a2d398 in getNameInitAsString /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/TableGen/Record.h:1718:27
    #9 0x555c21a2d398 in llvm::TGParser::addDefOne(std::__1::unique_ptr<llvm::Record, std::__1::default_delete<llvm::Record>>) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/TableGen/TGParser.cpp:545:42
    #10 0x555c21a2bc41 in llvm::TGParser::addEntry(llvm::RecordsEntry) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/TableGen/TGParser.cpp:416:10
    #11 0x555c21a5948e in llvm::TGParser::ParseDef(llvm::MultiClass*) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/TableGen/TGParser.cpp:3625:10
    #12 0x555c21a5ccab in llvm::TGParser::ParseObject(llvm::MultiClass*) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/TableGen/TGParser.cpp:4325:31
    #13 0x555c21a651f1 in ParseObjectList /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/TableGen/TGParser.cpp:4356:9
    #14 0x555c21a651f1 in llvm::TGParser::ParseFile() /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/TableGen/TGParser.cpp:4365:7
    #15 0x555c219ba36f in llvm::TableGenMain(char const*, std::__1::function<bool (llvm::raw_ostream&, llvm::RecordKeeper&)>) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/TableGen/Main.cpp:125:14
    #16 0x555c218986c5 in main /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/TableGen/TableGen.cpp:84:10
    #17 0x7f0373e2814f  (/lib/x86_64-linux-gnu/libc.so.6+0x2814f) (BuildId: 6a981b07a3731293c24c10a21397416d3c3d52ed)
```

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


More information about the cfe-commits mailing list