llvm / llvm/llvm-project

[compiler-rt][tysan] False positives with Abseil hash containers

Open
#208,653 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

# absl `flat_hash_map`
#### Flags: `-stdlib=libc++ -fsanitize=type -O0`
#### Compiler: x86-64 clang 22.1.0
#### Link: https://godbolt.org/z/YezqaebzT
#### Code:
```.cpp
#include "absl/container/flat_hash_map.h"
#include

int main() {
absl::flat_hash_map m;
m.reserve(2);
std::string long_string = std::string(100, 'a');
m.emplace(long_string, 0);
int access = m[long_string];
}
```
Static version:
```.cpp
#include

int main() {
static absl::flat_hash_map m;
m[1] = 1;
}
```
#### Logs:
```
==1==ERROR: TypeSanitizer: type-aliasing-violation on address 0x7ffc0df37308 (pc 0x5db1c18dce6c bp 0x7ffc0df371e0 sp 0x7ffc0df37170 tid 1)
WRITE of size 8 at 0x7ffc0df37308 with type long (in absl::lts_20260107::uint128 at offset 8) accesses an existing object of type p1 _ZTSN4absl12lts_202601077uint128E
#0 0x5db1c18dce6b (/app/output.s+0x7de6b)

==1==ERROR: TypeSanitizer: type-aliasing-violation on address 0x7ffc0df36fc8 (pc 0x5db1c18dce6c bp 0x7ffc0df36ea0 sp 0x7ffc0df36e30 tid 1)
WRITE of size 8 at 0x7ffc0df36fc8 with type long (in absl::lts_20260107::uint128 at offset 8) accesses an existing object of type p1 _ZTSN4absl12lts_202601077uint128E
#0 0x5db1c18dce6b (/app/output.s+0x7de6b)
...
```
#### Explanation:
Likely a internal type-punning-ish layout violation.
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 absl containers seems still problematic...

Contributor guide

Open the contributing guide

Research direction

Start by running the provided absl::flat_hash_map reproductions with clang 22.1.0, -stdlib=libc++, -fsanitize=type, and -O0, using the linked Godbolt examples for comparison. Investigate the TypeSanitizer reports involving absl::uint128 and confirm that both dynamic and global/static containers complete without 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.