From ae8272787f2f7227f7cfec812d8d1b0bacb4996a Mon Sep 17 00:00:00 2001 From: Yuval Tassa Date: Thu, 20 Nov 2025 12:29:35 -0800 Subject: [PATCH] Rollback of 7cb2e31f4b5d4bdd4b5174efb2793e10b6bb3d00 PiperOrigin-RevId: 834865905 Change-Id: Iade490754ca30a97f696bcb09525f9b4c37dbeff --- src/xml/xml_api.cc | 43 ------------------------------------------- 1 file changed, 43 deletions(-) diff --git a/src/xml/xml_api.cc b/src/xml/xml_api.cc index 43ccf803..b722ceaf 100644 --- a/src/xml/xml_api.cc +++ b/src/xml/xml_api.cc @@ -38,31 +38,6 @@ #include #endif - -// leak sanitizer support: default to no-op -#define MJ_LSAN_IGNORE(ptr) ((void)(ptr)) - -// on Linux with GCC/Clang and LSAN available -#if (defined(__GNUC__) || defined(__clang__)) && !defined(__APPLE__) && !defined(_WIN32) -#ifdef __has_include -#if __has_include() - -// define weak lsan_ignore_object symbol -#include -extern "C" void __lsan_ignore_object(const void*) __attribute__((weak)); -namespace { -inline void lsan_ignore(const void* ptr) { if (__lsan_ignore_object) __lsan_ignore_object(ptr); } -} // namespace - -// redefine MJ_LSAN_IGNORE to use lsan_ignore -#undef MJ_LSAN_IGNORE -#define MJ_LSAN_IGNORE(ptr) lsan_ignore(ptr) - -#endif // LSAN API available -#endif // __has_include -#endif // Linux with GCC/Clang - - //---------------------------------- Globals ------------------------------------------------------- namespace { @@ -77,12 +52,6 @@ class GlobalModel { std::optional ToXML(const mjModel* m, char* error, int error_sz); - // mark this GlobalModel and its allocations as intentional (not leaks) - void AnnotateLSan() { - MJ_LSAN_IGNORE(this); - MJ_LSAN_IGNORE(mutex_); - } - private: // using raw pointers as GlobalModel needs to be trivially destructible std::mutex* mutex_ = new std::mutex(); @@ -109,11 +78,6 @@ void GlobalModel::Set(mjSpec* spec) { mj_deleteSpec(spec_); } spec_ = spec; - - // mark the spec as an intentional long-lived allocation - if (spec_) { - MJ_LSAN_IGNORE(spec_); - } } @@ -121,13 +85,6 @@ void GlobalModel::Set(mjSpec* spec) { GlobalModel& GetGlobalModel() { static GlobalModel global_model; - // mark the GlobalModel singleton and its mutex as intentional allocations - static bool lsan_annotated = false; - if (!lsan_annotated) { - global_model.AnnotateLSan(); - lsan_annotated = true; - } - // global variables must be trivially destructible static_assert(std::is_trivially_destructible_v); return global_model;