]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
common/weighted_shuffle: don't feed std::discrete_distribution with all-zero weights
authorRadosław Zarzyński <rzarzyns@redhat.com>
Wed, 30 Aug 2023 13:19:07 +0000 (15:19 +0200)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Thu, 11 Jan 2024 20:14:36 +0000 (20:14 +0000)
commita64443aaeec78ebd53e41e646d65d30232b5b68f
tree20aab88c9611f2939b83723caec595cda5e4773c
parent8a49823274852950a14491e70fcb3b5976733558
common/weighted_shuffle: don't feed std::discrete_distribution with all-zero weights

This flaw results is the assertions like the following one:

```
/usr/include/c++/11/bits/random.tcc:2667: void std::discrete_distribution<_IntType>::param_type::_M_initialize() [with _IntType = int]: Assertion '__sum > 0' failed.
Aborted (core dumped)
```

The reason behind is that `std::discrete_distribution` sums
the weights and uses the result as a divisor.

Fixes: https://tracker.ceph.com/issues/62645
Signed-off-by: Radosław Zarzyński <rzarzyns@redhat.com>
(cherry picked from commit 1b7a7a8df88ffac007dbafdecc131807de66c046)
src/common/weighted_shuffle.h