<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Add a function to undo __lsan_ignore_object"
   href="https://bugs.llvm.org/show_bug.cgi?id=42287">42287</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Add a function to undo __lsan_ignore_object
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>compiler-rt
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>lsan
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>terrelln@fb.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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] <a href="https://github.com/facebook/folly/blob/master/folly/memory/SanitizeLeak.h">https://github.com/facebook/folly/blob/master/folly/memory/SanitizeLeak.h</a>
[2]
<a href="https://github.com/facebook/folly/blob/master/folly/concurrency/AtomicSharedPtr.h">https://github.com/facebook/folly/blob/master/folly/concurrency/AtomicSharedPtr.h</a></pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>