[clang] [Clang] Mark this pointer in destructors dead_on_return (PR #166276)

Aiden Grossman via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 1 16:52:45 PST 2025


boomanaiden154 wrote:

> Is the potential undefined behavior here checked by msan? Do we need to disable adding this attribute if msan is enabled?

Yes, use-after-destroy is checked by msan, but I don't believe we need to explicitly disable anything here to handle msan. Based on my understand, the msan instrumentation will add a call to `__sanitizer_dtor_callback_fields` at the end of the destructor, passing in the `this` pointer along with the object size. `__sanitizer_dtor_callback_fields` then modifies the shadow memory, which is a separate object that is not marked dead by this change.

CC @thurstond Who is more familiar with the internals of msan and would be able to confirm.

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


More information about the cfe-commits mailing list