[MLton] wiki cvs-like tool

Matthew Fluet fluet@cs.cornell.edu
Thu, 18 Nov 2004 18:14:42 -0500 (EST)

> I don't trust Cygwin, so I tweaked Posix_IO_read to malloc its own
> buffer and pass that to read, then memcpy the buffer to the SML
> buffer.  That did not affect the behavior at all (i.e. I still get
> EINVAL).  I'd be curious to see what that does on your system.  It
> would offer more conclusive evidence of confusion on Cygwin's part if
> we get EFAULT with a buffer that we just malloc'd.

I modified Posix_IO_read as follows:

Ssize Posix_IO_read (Fd fd, Pointer b, Int i, Size s) {
	fprintf(stderr, "Posix_IO_read(%ld, 0x%08x, %ld, %ld):\n",
                fd, (uint)b, i, s);
        void *buf = malloc(s);
	fprintf(stderr, "\tbuf = 0x%08x\n", (uint)buf);
	Ssize res = (Ssize)(read (fd, buf, s));
	fprintf(stderr, "\tres = %ld\n", res);
	memcpy((void *) ((char *) b + i), buf, s);
	return res;

	return (Ssize)(read (fd, (void *) ((char *) b + i), s));

Running, I continue to get "Bad address":

$ ./wiki login http://mlton.org MatthewFluet foobar
Posix_IO_read(3, 0x011f1428, 0, 4096):
        buf = 0x10030228
        res = 1190
Posix_IO_read(3, 0x012f4efc, 0, 4096):
        buf = 0x10031230
        res = -1
inputAll <socket>: Bad address

So, that seems to suggest Cygwin weirdness.