Inconsistency between find and traversing with iterators
- 主要语言
- C++
- 星标
- 18.1k
- 派生
- 3.2k
- 平均合并
- 20 小时 36 分钟
- 30 天内合并 PR
- 1
描述
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.
贡献指南
评估
这个 Issue 还没有评估数据。