Thanks for the help!

When the optimize converts

 (let-values ([(X ...) (values M ...)])
   ....)

to

 (let ([X M] ...)
   ....)

it incorrectly attaches a virtual timestamp to each "[X M]" binding
that corresponds to the timestamp after the whole `(values M ...)`.

So, the optimizer loses the fact that in `(values (car xy) (cdr xy))`
the `(cdr xy)` happens after the `(car xy)`. It later ends up swapping
the order of those expressions, which is a particular problem when
`(cdr xy)` was changed to `(unsafe-cdr xy)` on the grounds that it
happens after `(car xy)`.

At Sun, 13 Sep 2015 12:15:33 +0200, antoine wrote:
> Bonjour,
> 
> The bytecode generated is:
> 
> (begin
>   (module test ....
>     (require (lib "racket/base.rkt"))
>     (provide)
>     (module configure-runtime ....
>       (require '#%kernel (lib "racket/runtime-config.rkt"))
>       (provide)
>       (print-as-expression '#t))
>     (define-values
>      (_split&flip)
>      (begin
>        '%%inline-variant%%
>        (#%closed
>         split&flip28
>         (lambda (arg0-30)
>           '#(split&flip #<path:/tmp/test.rkt> 3 0 20 90 #f)
>           (values (unsafe-cdr arg0-30) (car arg0-30))))
>        (#%closed
>         split&flip27
>         (lambda (arg0-35)
>           '#(split&flip #<path:/tmp/test.rkt> 3 0 20 90 #f)
>           (values (unsafe-cdr arg0-35) (car (#%sfs-clear arg0-35)))))))
>     (define-values
>      (_a _b)
>      (let ((local40 (cons '0 '1)))
>        (values (unsafe-cdr local40) (unsafe-car local40))))
>     (#%apply-values
>      |_print-values:p@(lib "racket/private/modbeg.rkt")|
>      (values (unsafe-cdr _b) (car _b)))))
> 
> 
> Not familiar with the bytecode but a quick look at
> http://docs.racket-lang.org/raco/decompile.html about %%inline-variant%% make 
> me
> think split&flip28 is over enthousiastic about
> 
> (values (unsafe-cdr arg0-30) (car arg0-30))
> 
> and should have generated:
> 
> (values (cdr arg0-30) (car arg0-30))
> 
> By the way it also segfault to me, 32bit, linux 6.2 release.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to