https://bugs.llvm.org/show_bug.cgi?id=42287

            Bug ID: 42287
           Summary: Add a function to undo __lsan_ignore_object
           Product: compiler-rt
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: lsan
          Assignee: unassignedb...@nondot.org
          Reporter: terre...@fb.com
                CC: llvm-bugs@lists.llvm.org

I recently added leak sanitizer suppressions to Facebook's folly library [1].
We don't use __lsan_ignore_object() because you can't undo the operation. Can
we add a function to remember an object we've previously ignored?

An example where this is useful:

```
#include <folly/concurrency/AtomicSharedPtr.h>
#include <folly/memory/SanitizeLeak.h>

class Data;
class LeakedDataPtr {
 public:
  std::shared_ptr<const Data> get() const {
    return ptr_.load();
  }

  void update(std::shared_ptr<const Data> data) {
    auto newPtr = data.get();
    auto old = ptr_.exchange(std::move(data));
    folly::annotate_object_collected(old.get());
    folly::annotate_object_leaked(newPtr);
  }

  static LeakedDataPtr& instance() {
    static auto* instancePtr = new LeakedDataPtr();
    return *instancePtr;
  }

 private:
  folly::atomic_shared_ptr<const Data> ptr_;
};
```

[1] https://github.com/facebook/folly/blob/master/folly/memory/SanitizeLeak.h
[2]
https://github.com/facebook/folly/blob/master/folly/concurrency/AtomicSharedPtr.h

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to