[compiler-rt] [CFI] update ignorelist to work with libstdc++ make_shared (PR #118599)

Jonathan Wakely via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 9 02:17:03 PST 2024


jwakely wrote:

Is the correct fix really to just add an allow-list for individual cases of valid code? Doesn't that imply a problem with the sanitizer, or is that by design?

This PR doesn't help this case, which fails using both -stdlib=libstdc++ and -stdlib=libc++, and is valid C++ as far as I can see:

```c++
#include <new>

namespace x __attribute__((visibility("default")))
{
template<typename T>
struct buffer
{
  alignas(__alignof__(T)) unsigned char buf[sizeof(T)];

  void* addr() { return static_cast<void*>(buf); }

  T* ptr() { return static_cast<T*>(addr()); }
};
}

struct IReporterFactory {
    virtual ~IReporterFactory() = default;
};

class ReporterFactory : public IReporterFactory {};

int main()
{
  auto p = new x::buffer<ReporterFactory>;
  auto p2 = p->ptr();  // undefined here
  ::new(static_cast<void*>(p2)) ReporterFactory;
  p->ptr()->~ReporterFactory();
  delete p;
}
```

And it doesn't help for this case which fails using -stdlib=libstdc++:

```c++
#include <list>

struct IReporterFactory {
    virtual ~IReporterFactory() = default;
};

class ReporterFactory : public IReporterFactory {};

int main()
{
  std::list<ReporterFactory> l(1);
}
```
(I plan to change the node-based containers in libstdc++ to use a union for the uninitialized storage, which should fix this case ... one day.)


https://github.com/llvm/llvm-project/pull/118599


More information about the llvm-commits mailing list