abseil / abseil/abseil-cpp

Inconsistency between find and traversing with iterators

Open
#1,193 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
18.1k
Forks
3.2k
Avg merge
20h 36m
Merged PRs (30d)
1

Description

Hi all;
I recently replaced the hash tables in my code with abseil hash. I notice the following abnormal behavior in some of my tests. I look up for an element with find and it is saying is not there then I print all key values in the container and I see the element being actually present.

```
typedef absl::flat_hash_map
, absl::container_internal::hash_default_eq
, Allocator> // Our own Allocator
> map_t;

auto hit = hashIndexA.map.find(hashCode);
if (hit == hashIndexA.map.end()) {
cout<<&hashIndexA<<&(hashIndexA.map)<<"::element not found:"<first<<"::"<second<<"\n";
}

sample output:
0xffff62a2d0d00xffff62a2d128::element not found:-1574725910
HASHINDEX:-1574725910::2
HASHINDEX:-1574733349::5
```

This is with C++11, Abseil-lts_2020_09_23 and the only maybe special thing here is that the map is created in one thread and potentially read in a separate thread . There is no concurrent access. The table is completely created by one thread and later on the other thread is is reading the data.

Maybe by luck , when replacing the default hashing function with std::hash my tests are passing.
Also the tests always pass in debug mode. The issue is only present in -g -O2 mode.

I was wondering if anybody else hit this issue in the past and if there are any flags that can be set ?

Are there any thread local storage issues that may affect the behavior in my scenario ?

Unfortunately I don;t have an individual reproducer. For me these are hundred of complex tests doing joins, distinct, group by in the context of a database.

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.