[plt-scheme] read (compiled): ill-formed code
Sorry --- I forgot about this. I haven't been able to replicate the
problem. Does it still happen for you with the latest (rev 18744 or
later)?
When I first tried, I ran into a new problem, which was related to
locking that I added for lazy module instantiation. (That's why I
specify rev 18744 or later.) It seems possible that the bug was related
to the lack of locking at the time you wrote your message, but I don't
quite see how it would happen.
Thanks for the fix to `unsafe-flmin' and `unsafe-flmax'. I adjusted the
test suite to generate foldable expressions. No surprise, I had made
the same mistake with `unsafe-fxmin' and `unsafe-fxmax'. Also,
constant-folding with `unsafe-flsqrt' was broken on negative arguments.
At Wed, 24 Mar 2010 11:28:15 +0000, Noel Welsh wrote:
> 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?