Bug 21578 – core.atomic.atomicFetchSub for pointers incorrectly calls wrong function from core.internal.atomic

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-01-24T23:16:37Z
Last change time
2021-02-13T03:32:44Z
Keywords
pull
Assigned to
No Owner
Creator
ZombineDev

Comments

Comment #0 by petar.p.kirov — 2021-01-24T23:16:37Z
Likely due to a copy-paste bug `core.atomic.atomicFetchSub` wrongly calls `core.internal.atomic.atomicFetchAdd` instead of `core.internal.atomic.atomicFetchSub`.
Comment #1 by petar.p.kirov — 2021-01-24T23:22:21Z
Test case: import core.atomic; shared(ulong)[] array = [2, 4, 6, 8, 10, 12, 14, 16, 19, 20]; { shared ulong* ptr = &array[0]; shared(ulong)* prevPtr = atomicFetchAdd(ptr, 3); assert(prevPtr == &array[0]); // OK assert(*prevPtr == 2); // OK assert(*ptr == 8); // OK } { shared ulong* ptr = &array[5]; shared(ulong)* prevPtr = atomicFetchSub(ptr, 4); assert(prevPtr == &array[5]); // OK assert(*prevPtr == 12); // OK assert(*ptr == 4); //fails }
Comment #2 by dlang-bot — 2021-01-25T09:18:27Z
@rymrg created dlang/druntime pull request #3343 "Fix issue 21578 - core.atomic.atomicFetchSub for pointers incorrectly…" fixing this issue: - Fix issue 21578 - core.atomic.atomicFetchSub for pointers incorrectly calls wrong function from core.internal.atomic https://github.com/dlang/druntime/pull/3343
Comment #3 by dlang-bot — 2021-01-27T02:34:39Z
dlang/druntime pull request #3343 "Fix issue 21578 - core.atomic.atomicFetchSub for pointers incorrectly…" was merged into stable: - fbf5f525756e51879578c2663643449a5c9c4040 by rymrg: Fix issue 21578 - core.atomic.atomicFetchSub for pointers incorrectly calls wrong function from core.internal.atomic https://github.com/dlang/druntime/pull/3343
Comment #4 by dlang-bot — 2021-02-13T03:32:44Z
dlang/druntime pull request #3374 "merge stable" was merged into master: - 2d1f8efbe72c2a9712e055e617285a0f5661f9f3 by rymrg: Fix issue 21578 - core.atomic.atomicFetchSub for pointers incorrectly calls wrong function from core.internal.atomic https://github.com/dlang/druntime/pull/3374