marcomaggi / vicare

A native compiler for Scheme compliant with R6RS
http://marcomaggi.github.com/vicare.html
Other
200 stars 34 forks source link

in debug mode, incorrect handling of quasiquoted expressions #3

Closed marcomaggi closed 12 years ago

marcomaggi commented 14 years ago

Running the program below as:

$ ikarus --r6rs-script hurtme.sps
ciao

while in debug mode:

$ ikarus --debug --r6rs-script hurtme.sps
ciao
ciao

(import (rnrs))
(define (b)
  (display "ciao\n"))
(quasiquote (,(b)))

notice that changing the expression to "(quasiquote ,(b))" does not exercise the bug.

This is bug #563577 in the Ikarus bug tracker.

marcomaggi commented 14 years ago

It happens only when debug mode is on along with optimize level 2; also changing the following in "ikarus.compiler.source-optimizer.ss":

  [(2)
   (source-optimize expr)]

to:

  [(2)
   (parameterize ([cp0-size-limit 0])
   (source-optimize expr))]

makes the problem go away.

marcomaggi commented 14 years ago

The bug goes away for the simple test script, but not in more complicated cases having the same quasiquote use. It seems the only way to go around this is to set optimisation level to zero from the command line, rc file or to force it to zero artificially at process start.

marcomaggi commented 12 years ago

Reopening this issue be cause in the head of the assembler branch the source optimizer has been reenabled. The bug is still there when running:

$ vicare -O2 --debug script.sps

or:

$ vicare -O1 --debug script.sps
marcomaggi commented 12 years ago

This bug has nothing to do with quasiquote. The following program:

(import (rnrs))
(vector (display "ciao\n"))
(flush-output-port (current-output-port))

will print twice "ciao" with both the latest vicare from the assembler branch and the latest available ikarus, both when running with options '--debug -O1'; without --debug or without -O1 no error happens.

The problem is that somehow the function debug-call wrapping the function call sin the program is called twice with the same arguments.

Unless I am mistaken: this does not happen at the REPL, only with programs.

marcomaggi commented 12 years ago

This should be fixed in the head of the assembler branch.