abseil / abseil/abseil-cpp

Inconsistency between find and traversing with iterators

Đang mở
#1,193 7 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
C++
Star
18.1k
Fork
3.2k
Merge trung bình
20 giờ 36 phút
Pull request đã merge (30 ngày)
1

Mô tả

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.