2
0
mirror of https://github.com/boostorg/atomic.git synced 2026-01-19 04:02:09 +00:00

Fixed pointer arithmetics in wait state initialization on reallocation.

Fixes https://github.com/boostorg/atomic/issues/72.
This commit is contained in:
Andrey Semashev
2024-11-21 20:06:41 +03:00
parent b202228311
commit 5e2e016668
2 changed files with 6 additions and 2 deletions

View File

@@ -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)`.

View File

@@ -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
{