Use-after-dtor detection for trivial base classes.
authorEvgenii Stepanov <eugenis@google.com>
Wed, 16 Mar 2022 01:43:30 +0000 (18:43 -0700)
committerVitaly Buka <vitalybuka@google.com>
Thu, 17 Mar 2022 01:20:27 +0000 (18:20 -0700)
commitc5ea8e9138931b74b60221f667da304e244dc57d
tree83690343da5fe8a4eb6467c1a772cc729605f297
parent3587b15abe683f164093f8d057e921f913572007
Use-after-dtor detection for trivial base classes.

-fsanitize-memory-use-after-dtor detects memory access after a
subobject is destroyed but its memory is not yet deallocated.
This is done by poisoning each object memory near the end of its destructor.

Subobjects (members and base classes) do this in their respective
destructors, and the parent class does the same for its members with
trivial destructors.

Inexplicably, base classes with trivial destructors are not handled at
all. This change fixes this oversight by adding the base class poisoning logic
to the parent class destructor.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D119300
clang/lib/CodeGen/CGClass.cpp
clang/test/CodeGenCXX/sanitize-dtor-trivial-base.cpp [new file with mode: 0644]
compiler-rt/test/msan/dtor-base-access.cpp