llvm / llvm/llvm-project

[compiler-rt][tysan] False positives with Boost static_vector

Open
#208,654 0 comments 0 reactions 0 assignees View on GitHub
compiler-rt:tysan false-positive needs-reduction
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

# `boost::static_vector`
#### Flags: `-stdlib=libc++ -fsanitize=type -O0` or `-stdlib=libc++ -fsanitize=type -O1`
#### Compiler: x86-64 clang 22.1.0
#### Link: https://godbolt.org/z/jM4M41avM
#### Code:
```.cpp
#include

int main() {
static boost::container::static_vector v;
v.emplace_back(2);
v.emplace_back(1);
}

```
#### Logs:
```
==1==ERROR: TypeSanitizer: type-aliasing-violation on address 0x580d0ac6af28 (pc 0x580d0a310053 bp 0x7ffeed94c620 sp 0x7ffeed94c5b0 tid 1)
WRITE of size 8 at 0x580d0ac6af28 with type long accesses an existing object of type boost::container::static_vector
#0 0x580d0a310052 (/app/output.s+0x37052)

==1==ERROR: TypeSanitizer: type-aliasing-violation on address 0x580d0ac6af30 (pc 0x580d0a3100dd bp 0x7ffeed94c620 sp 0x7ffeed94c5b0 tid 1)
WRITE of size 8 at 0x580d0ac6af30 with type long accesses part of an existing object of type boost::container::static_vector that starts at offset -8
#0 0x580d0a3100dc (/app/output.s+0x370dc)
```
#### Explanation:

Global/Static STL containers used to cause false positives in 20.1.0: https://godbolt.org/z/q3TsrK5c4
But fixed in 22.1.0: https://godbolt.org/z/1qE3z6eea
So, global/static boost containers seems not yet fixed.

Contributor guide

Open the contributing guide

Research direction

Reproduce the minimal boost::container::static_vector example with the listed libc++, type-sanitizer, optimization, and compiler settings using the linked Compiler Explorer case. Compare its diagnostics with the provided global/static STL-container examples, then investigate compiler-rt/tysan behavior. Done means the static Boost container no longer produces these false-positive type-aliasing violations.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.