llvm / llvm/llvm-project

MSAN does not always detect accessing uninitialized bytes after variant destroy

Open
#191,883 0 comments 0 reactions 0 assignees View on GitHub
compiler-rt:msan
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

```c++
std::variant v;
v.emplace();
double& d = std::get(v);
v.emplace();
if (d) ...
```

MSAN does not catch the above program, when the type being destroyed due to the second replace is trivial / does not have its own destructor.

See https://github.com/llvm/llvm-project/pull/101048 for background. The fix suggested by this PR (now closed, since that approach is not the right approach) is to emit a destructor call for the trivial case, and have the MSAN runtime properly poison the destructed bytes.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.