http://d.puremagic.com/issues/show_bug.cgi?id=7446

           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: nob...@puremagic.com
        ReportedBy: thecybersha...@gmail.com


--- Comment #0 from Vladimir Panteleev <thecybersha...@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)[])();
      stdout.rawWrite(buffer);
   }
}

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: -------

Reply via email to