abseil / abseil/abseil-cpp

Is it expected such test doesn't work with sanitizer?

Đang mở
#1,422 5 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ả

### Describe the issue

reserve to smaller than size capacity makes unsigned overflow in reset_reserved_growth
```cpp
void reset_reserved_growth(size_t reservation, size_t size) {
reserved_growth_ = reservation - size;
}
```

```cpp
TEST(Table, ReservedGrowthUpdatesWhenTableDoesntGrow2) {
IntTable t;
for (int i = 0; i < 8; ++i) t.insert(i);
// Want to insert twice without invalidating iterators so reserve.
const size_t cap = t.capacity();
t.reserve(3);
// We want to be testing the case in which the reserve doesn't grow the table.
ASSERT_EQ(cap, t.capacity());
auto it = t.find(0);
t.insert(100);
t.insert(200);
t.insert(300);
// `it` should have been invalidated.
EXPECT_EQ(*it, 0); // should be some expect_death
}
```

Is it expected?

### Steps to reproduce the problem

Run test

### What version of Abseil are you using?

master

### What operating system and version are you using?

Linux 6.2.6-arch1-1

### What compiler and version are you using?

clang version 15.0.7
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/12.2.1
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.1
Selected GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.1
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64

### What build system are you using?

cmake version 3.26.1

CMake suite maintained and supported by Kitware (kitware.com/cmake).

### Additional context

I think fix should be like make reset_reserved_growth call inside raw_hash_set::resize
https://github.com/abseil/abseil-cpp/pull/1423

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.