www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7446] New: [TDPL] Trivial asynchronous file copy example crashes with OwnerTerminated


           Summary: [TDPL] Trivial asynchronous file copy example crashes
                    with OwnerTerminated
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: TDPL
          Severity: normal
          Priority: P2
         Component: druntime
        AssignedTo: nobody puremagic.com
        ReportedBy: thecybershadow gmail.com

--- Comment #0 from Vladimir Panteleev <thecybershadow gmail.com> 2012-02-05
14:56:13 PST ---
import std.concurrency, std.stdio;

void main() {
   enum bufferSize = 1024 * 100;
   auto tid = spawn(&fileWriter);
   // Read loop
   foreach (ubyte[] buffer; stdin.byChunk(bufferSize)) {
      send(tid, buffer.idup);

void fileWriter() {
   // Write loop
   for (;;) {
      auto buffer = receiveOnly!(immutable(ubyte)[])();

TDPL says: "The writer thread exits with the OwnerTerminated exception, which
is recognized by the runtime system, which simply ignores it."

This program will cat stdin to stdout as expected, however on exit it will
apparently crash with an OwnerTerminated exception.

I should point out another oddity: the exception information (class, message,
stack trace) are printed to STDOUT, not STDERR. When using this example program
to copy a file using pipes, the exception is appended to the destination file.

Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 05 2012