If stdout is __gshared, why does this throw / crash?

Atila Neves via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Mar 6 01:34:38 PST 2016


On Sunday, 6 March 2016 at 01:28:52 UTC, Marco Leise wrote:
> Got it now: https://issues.dlang.org/show_bug.cgi?id=15768
>
> writeln() creates a copy of the stdout struct in a non 
> thread-safe way. If stdout has been assigned a File struct 
> created from a file name this copy includes a "racy" 
> increment/decrement of a reference count to the underlying 
> C-library FILE*. In the case that the reference count is 
> erroneously reaching 0, the file is closed prematurely and when 
> Glibc tries to access internal data it results in the 
> observable SIGSEGV.

Nice, good work!

Atila


More information about the Digitalmars-d-learn mailing list