[plt-scheme] read (compiled): ill-formed code

From: Noel Welsh (noelwelsh at gmail.com)
Date: Wed Mar 24 07:28:15 EDT 2010

The code is here:

http://github.com/noelwelsh/bayesian-scan-matching/tree/optimisation

You can either download the code from a link on Github or pull down
the repository:

git clone git://github.com/noelwelsh/bayesian-scan-matching.git
cd bayesian-scan-matching/
git checkout optimisation

NB: You want the optimisation branch.

Then:

mzscheme
Welcome to MzScheme v4.2.5.1 [3m], Copyright (c) 2004-2010 PLT Scheme Inc.
> (require (planet schematics/schemeunit:3/text-ui) "all-tests.ss")
> (run-tests all-tests)

All is good. Now, compile the code to break it:

mzc all-tests.ss
noel at Quixotic/tmp/bayesian-scan-matching> mzscheme
Welcome to MzScheme v4.2.5.1 [3m], Copyright (c) 2004-2010 PLT Scheme Inc.
> (require (planet schematics/schemeunit:3/text-ui) "all-tests.ss")
> (run-tests all-tests)
--------------------
all-tests > place-tests > place-add and place-remove are inverses
place-add and place-remove are inverses
ERROR
UNKNOWN: read (compiled): ill-formed code
[../../../mzscheme/gc2/../src/eval.c:11632]


================================================

There is also a (probably unrelated) bug in unsafe-flmin and
unsafe-flmax. Try this:

> (require scheme/unsafe/ops)
> (unsafe-flmin 1.1 1.2)
#t

The error is in numcomp.c:

#define UNSAFE_FL_X(name, op, fold, T, F, PRE_CHECK)         \
 static Scheme_Object *name(int argc, Scheme_Object *argv[]) \
 {                                                           \
   if (scheme_current_thread->constant_folding) return (fold(argv[0],
argv[1]) ? scheme_true : scheme_false); \
   PRE_CHECK                                                 \
   if (SCHEME_DBL_VAL(argv[0]) op SCHEME_DBL_VAL(argv[1]))   \
     return T;                                               \
   else                                                      \
     return F;                                               \
 }

...

UNSAFE_FL_X(unsafe_fl_min, <, bin_min, argv[0], argv[1], CHECK_ARGV0_NAN)
UNSAFE_FL_X(unsafe_fl_max, >, bin_max, argv[0], argv[1], CHECK_ARGV0_NAN)

Two problems:

1. The constant folding code always returns #t or #f.
2. bin_min and bin_max are not boolean operations -- they return the min or max

I have fixed this on my local install by defining a new UNSAFE_FL
variant, but this seemed too big a change to commit to the trunk. I'll
send the diff in a bit... gotta go right now.

N.

On Tue, Mar 23, 2010 at 9:41 PM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
> I think this must be a bug in the compiler, bytecode marshaler,
> bytecode reader, or bytecode validator. Can you send me instructions to
> replicate the bug?


Posted on the users mailing list.