diff --git a/doc/changelog.qbk b/doc/changelog.qbk index b245f8f..a5d8a74 100644 --- a/doc/changelog.qbk +++ b/doc/changelog.qbk @@ -7,6 +7,10 @@ [section:changelog Changelog] +[heading Boost 1.87] + +* Fixed initialization of atomic wait state list on memory reallocation. ([github_issue 72]) + [heading Boost 1.86] * Use [@https://man.openbsd.org/OpenBSD-6.2/futex.2 `futex(2)`] system call on OpenBSD since recent OpenBSD versions have removed support for `syscall(2)`. diff --git a/src/lock_pool.cpp b/src/lock_pool.cpp index adbea62..7e92546 100644 --- a/src/lock_pool.cpp +++ b/src/lock_pool.cpp @@ -1252,11 +1252,11 @@ wait_state_list::header* wait_state_list::allocate_buffer(std::size_t new_capaci const volatile void** old_a = get_atomic_pointers(old_header); std::memcpy(a, old_a, old_header->size * sizeof(const volatile void*)); - std::memset(a + old_header->size * sizeof(const volatile void*), 0, (new_capacity - old_header->size) * sizeof(const volatile void*)); + std::memset(a + old_header->size, 0, (new_capacity - old_header->size) * sizeof(const volatile void*)); wait_state** old_w = get_wait_states(old_a, old_header->capacity); std::memcpy(w, old_w, old_header->capacity * sizeof(wait_state*)); // copy spare wait state pointers - std::memset(w + old_header->capacity * sizeof(wait_state*), 0, (new_capacity - old_header->capacity) * sizeof(wait_state*)); + std::memset(w + old_header->capacity, 0, (new_capacity - old_header->capacity) * sizeof(wait_state*)); } else {