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

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

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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: io-bug.tar.gz
Type: application/x-gzip
Size: 1382 bytes
Desc: not available
URL: <http://lists.racket-lang.org/dev/archive/attachments/20120620/dda160fc/attachment-0001.gz>

Posted on the dev mailing list.