[Issue 23624] New: Race condition in test runner for DMD
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Jan 13 19:38:22 UTC 2023
https://issues.dlang.org/show_bug.cgi?id=23624
Issue ID: 23624
Summary: Race condition in test runner for DMD
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: tools
Assignee: nobody at puremagic.com
Reporter: tim.dlang at t-online.de
The test runner for DMD uses parallel foreach
(https://github.com/dlang/dmd/blob/deb039f5f6740d4df0f09226d4ee02c450f75658/compiler/test/run.d#L189):
foreach (target; parallel(targets, 1))
{
log("run: %-(%s %)", target.args);
int status = spawnProcess(target.args, env, Config.none,
scriptDir).wait;
if (status != 0)
{
const string name = target.filename
? target.normalizedTestName
: "`unit` tests";
writeln(">>> TARGET FAILED: ", name);
failedTargets ~= name;
}
}
Appending to failedTargets inside the loop body could be a race condition,
because parallel can run the loop body from different threads. This could
result in a wrong value for failedTargets or crash the test runner.
I don't know if this happens in practice, though.
--
More information about the Digitalmars-d-bugs
mailing list