Bug 15751 – atomicLoad doesn't return stable result if compiled with -profile
Status
RESOLVED
Resolution
WORKSFORME
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2016-03-03T21:59:32Z
Last change time
2022-11-03T10:19:33Z
Assigned to
No Owner
Creator
Andrey Zherikov
Comments
Comment #0 by andrey.zherikov — 2016-03-03T21:59:32Z
atomicLoad() doesn't constantly return 0 in the following code if it's compiled with -profile option:
=================================
import core.atomic;
int main()
{
shared int s = 0;
return atomicLoad(s);
}
=================================
Compiler: DMD32 D Compiler v2.070.2
Compile command: dmd test.d -oftest_p -profile
Test command:
pass=0; fail=0;
for i in $(seq 1 100);
do
./test_p.exe && pass=$((pass+1)) || fail=$((fail+1));
done;
echo pass=$pass fail=$fail
Test command output (example):
pass=89 fail=11
Even adding "atomicStore(s, 0);" right before atomicLoad doesn't guarantee the result:
pass=95 fail=5
Comment #1 by chalucha — 2019-12-10T09:41:43Z
Seems to be fixed in 2.089.0
Tried on run.dlang.org with:
```
import core.atomic;
int main()
{
shared int s = 0;
foreach (_; 0..10)
{
auto res = atomicLoad(s);
if (res != 0) return 1;
}
return 0;
}
```
came to this when trying profile something with dmd-2.088.1
Comment #2 by razvan.nitu1305 — 2022-11-03T10:19:33Z