# HG changeset patch # User Gerald Squelart # Date 1520890012 -39600 # Node ID e4e466004d34b06fec1e4abddb0f537f9e74493c # Parent cf8982afa7df0f71dc1fca22a77e3553b207855f Bug 1442819 - Suppress UBSan false positive - r=froydnj MozReview-Commit-ID: 9pmmYc5gevV diff --git a/dom/media/doctor/DecoderDoctorLogger.h b/dom/media/doctor/DecoderDoctorLogger.h --- a/dom/media/doctor/DecoderDoctorLogger.h +++ b/dom/media/doctor/DecoderDoctorLogger.h @@ -280,17 +280,18 @@ public: Log(aSubjectTypeName, aSubjectPointer, DDLogCategory::_DerivedConstruction, "", DDLogValue{ DDLogObject{ DDLoggedTypeTraits::Name(), aBase } }); } template - static void LogConstruction(const Subject* aSubject) + static void + LogConstruction(const Subject* aSubject) { using Traits = DDLoggedTypeTraits; if (!Traits::HasBase::value) { Log(DDLoggedTypeTraits::Name(), aSubject, DDLogCategory::_Construction, "", DDLogValue{ DDNoValue{} }); @@ -473,20 +474,30 @@ private: // Base class to automatically record a class lifetime. Usage: // class SomeClass : public DecoderDoctorLifeLogger // { // ... template class DecoderDoctorLifeLogger { public: +#if defined(__clang__) + // This constructor is called before the `T` object is fully constructed, and + // pointers are not dereferenced anyway, so UBSan shouldn't check vptrs. + __attribute__((no_sanitize("vptr"))) +#endif DecoderDoctorLifeLogger() { DecoderDoctorLogger::LogConstruction(static_cast(this)); } +#if defined(__clang__) + // This destructor is called after the `T` object is partially destructed, and + // pointers are not dereferenced anyway, so UBSan shouldn't check vptrs. + __attribute__((no_sanitize("vptr"))) +#endif ~DecoderDoctorLifeLogger() { DecoderDoctorLogger::LogDestruction(static_cast(this)); } }; // Macros to help lazily-evaluate arguments, only after we have checked that // logging is enabled.