Skip to content

Commit

Permalink
suppress sanitizer warning about (expected) leak
Browse files Browse the repository at this point in the history
Signed-off-by: xinyu.wang <[email protected]>
  • Loading branch information
comicfans committed Sep 4, 2024
1 parent 905223a commit 1b432c9
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions include/class_loader/class_loader_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,15 @@ bool hasANonPurePluginLibraryBeenOpened();
CLASS_LOADER_PUBLIC
void hasANonPurePluginLibraryBeenOpened(bool hasIt);

#if defined(__has_feature)
#if __has_feature(address_sanitizer) // for clang
#define __SANITIZE_ADDRESS__ // GCC already sets this
#endif
#endif

#if defined(__SANITIZE_ADDRESS__)
#include <sanitizer/lsan_interface.h>
#endif
// Plugin Functions

/**
Expand Down Expand Up @@ -207,6 +216,11 @@ void registerPlugin(const std::string & class_name, const std::string & base_cla
// Create factory
impl::AbstractMetaObject<Base> * new_factory =
new impl::MetaObject<Derived, Base>(class_name, base_class_name);

#if defined(__SANITIZE_ADDRESS__)
__lsan_ignore_object(new_factory);
#endif

new_factory->addOwningClassLoader(getCurrentlyActiveClassLoader());
new_factory->setAssociatedLibraryPath(getCurrentlyLoadingLibraryName());

Expand Down

0 comments on commit 1b432c9

Please sign in to comment.