[racket-dev] Bug in Racket's I/O?

From: Tony Garnock-Jones (tonyg at ccs.neu.edu)
Date: Wed Jun 20 20:25:35 EDT 2012

Sorry, I should have filed a bug report instead of mailing the list. I'm
filing the report now.

On 2012-06-20 8:22 PM, Tony Garnock-Jones wrote:
> Hi all,
> I think I've found a bug in Racket's I/O. Please interpret the following
> text as relating to the attached tarball with a small example of the
> problem. The problem manifests for me on both platforms I've tried, OS X
> and Linux.
> When `sync`ing on `read-bytes-evt` at the same time as on `alarm-evt`,
> it seems that if the `read-bytes-evt` would have come ready but the
> `alarm-evt` is the one actually chosen, the input from
> `read-bytes-evt` gets corrupted. This only seems to happen if a single
> `read-bytes-evt` instance is reused! If a fresh `read-bytes-evt` is
> constructed every time, the input stream remains uncorrupted.
> To see this, run `racket buggy-server.rkt 0`, which uses a single
> `read-bytes-evt` instance but does not use any `alarm-evt`
> instances. In another terminal, run `./run-test-osx.sh` (or
> `./run-test-linux.sh`, as appropriate). The program
> `./run-test-osx.sh` should terminate without producing any output.
> Now, kill off the instance of `buggy-server.rkt`, and start another,
> this time by running `racket buggy-server.rkt 1`. This instance uses
> both a single `read-bytes-evt` instance and an `alarm-evt`
> instance. Now, running `./run-test-osx.sh` should still produce no
> output, but in fact on most runs, some output (from diffing the input
> against the output of the socket) is produced, meaning that the echoed
> output differed from the input.
> Regards,
>   Tony
> _________________________
>   Racket Developers list:
>   http://lists.racket-lang.org/dev

Posted on the dev mailing list.