Bug 7149 – Segfault on Array Append from Multiple Threads in GDC and LDC: Race Condition?
Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P2
Component
druntime
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-12-21T20:49:00Z
Last change time
2013-10-28T02:30:15Z
Assigned to
nobody
Creator
dsimcha
Comments
Comment #0 by dsimcha — 2011-12-21T20:49:31Z
import core.thread;
void main() {
auto t = new Thread(&doIt);
t.start();
doIt();
}
void doIt() {
while(1) {
int[] arr1, arr2;
double[] arr3;
foreach(i; 0..10_000) {
arr1 ~= 1;
arr2 ~= 2;
arr3 ~= 3;
}
}
}
This code segfaults on both GDC (https://bitbucket.org/goshawk/gdc/issue/295/null-pointer-deref-in-_d_arrayappendctp) and LDC (https://github.com/ldc-developers/ldc/issues/56). It works on DMD or of doIt() is only called from one thread.
Since this is broken on both GDC and LDC it's worth having a bug report in the main druntime database. My gut feeling is that there's a concurrency bug that's triggered by some compiler optimization that GDC and LDC do but DMD doesn't do.
Comment #1 by safety0ff.bugz — 2013-10-28T02:23:21Z
The LDC & GDC issues have been closed in their trackers, can this be closed?