If stdout is __gshared, why does this throw / crash?
Yuxuan Shui via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Mar 5 15:52:53 PST 2016
On Saturday, 5 March 2016 at 14:18:31 UTC, Atila Neves wrote:
> With a small number of threads, things work as intended in the
> code below. But with 1000, on my machine it either crashes or
> throws an exception:
>
>
> import std.stdio;
> import std.parallelism;
> import std.range;
>
>
> void main() {
> stdout = File("/dev/null", "w");
> foreach(t; 1000.iota.parallel) {
> writeln("Oops");
> }
> }
>
>
>
> I get, depending on the run, "Bad file descriptor", "Attempting
> to write to a closed file", or segfaults. What am I doing wrong?
>
> Atila
Could this be a bug in phobos/compiler?
More information about the Digitalmars-d-learn
mailing list