[racket] A strange DrRacket interaction

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Fri Feb 8 10:08:24 EST 2013

2013/2/7 Jens Axel Søgaard <jensaxel at soegaard.net>:

This is an update:

  1. Danny confirms that the bug is repeatable on his machine.

  2. Weirdness on first character of the input reminded him
      on this bug:
          http://comments.gmane.org/gmane.comp.lang.racket.user/1759

 3. Wrapping the call to system* with
     (parameterize ([current-input-port (open-input-bytes #"abcde\n") …)
     make the program works expected.

The last point imply that the behaviour has something to do with the
"buffer ports" that DrRackets sets up to convert from ports used
in DrRacket to the file-stream-port need by system*.

4.  The equivalent C program (see below) does not trigger the error.

#include <stdio.h>
int main(int argc, char **argv) {
   char str[200];
   printf("Enter string:\n");
   fgets(str, 200, stdin);
   printf("%s\n",str);
   return 0;
}

/Jens Axel



> I am basically calling (system* "fpctest") where
> fpctest is the result of compiling this program with fpc:
>
> program fpctest;
> var s:string;
> begin
>   writeln('Enter string:');
>   readln(s);
>   writeln(s);
>   writeln('hello');
> end.
>
> The interaction in DrRacket is:
>
> 1. Input box appears
> 2. I enter   abcdef
> 3. abcdef appears where the input box was displayed.
> 4. This error messages is displayed:
>         .../Racket v5.3.2/collects/racket/private/port.rkt:128:15:
>          write-bytes-avail: output port is closed
> 5. The following is displayed:
>     Enter string:
>     bcdef
>     hello
>
> There are three things of interest:
>   1. The input box appears before "Enter string" is
>        written to the screen.
>      (Is this the Pascal program misbehaving?)
> 2. The error that points to a private file, which
>     seems odd.
> 3. The a is missing from the output of the
>      Pascal program.
>
> Running the program from command line racket
> seems to work every time.
>
> Once in while (say 1 out of 10 times) it works in DrRacket too.
>
> Any ideas what can explain what I see?
>
> Images: http://imgur.com/wSE6De5
>               http://imgur.com/hdYJcKx


Posted on the users mailing list.