Bug 21893 – core.atomic calls itself recursively

Status
NEW
Severity
regression
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-05-05T17:04:12Z
Last change time
2024-12-07T13:41:08Z
Assigned to
No Owner
Creator
Richard (Rikki) Andrew Cattermole
Moved to GitHub: dmd#17194 →

Comments

Comment #0 by alphaglosined — 2021-05-05T17:04:12Z
Windows, ldc2 1.25.1 64bit, the source matches up for this in druntime ~master. Known to happen in atomicLoad, atomicStore during testing. But I would expect it to also apply to atomicFetchAdd and atomicFetchSub. Making the function calls for the same name explicit to use core.internal.atomic fixes the issue i.e. atomicStore!ms(*cast(T*)&val, *cast(Thunk*)&newval); becomes core.internal.atomic.atomicStore!ms(cast(T*)&val, *cast(Thunk*)&newval); Without these changes, the arguments line up with itself and will end in a stack overflow.
Comment #1 by alphaglosined — 2021-05-05T17:24:35Z
cas also appears to suffer from this issue: https://github.com/dlang/druntime/blob/master/src/core/atomic.d#L386 return atomicCompareExchangeStrongNoResult!(succ, fail)(cast(T*)here, *cast(Thunk1*)&ifThis, *cast(Thunk2*)&writeThis); Since this was asked by Herringway on IRC, this was patched live and after patching it no longer appears to call itself recursively. I don't know how valid these proposed fixes are, only it seems to resolve it for my use case (Struct*[2]).
Comment #2 by dlang-bot — 2024-01-01T12:28:21Z
@avaxar created dlang/dmd pull request #15973 "Fix issue 21893 - Fix `std.atomic.atomicStore` infinitely and recursively calling itself" mentioning this issue: - Do changes from issue #21893 https://github.com/dlang/dmd/pull/15973
Comment #3 by robert.schadek — 2024-12-07T13:41:08Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17194 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB