[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-hackers] [PATCH] Fix for "parameterize" regression (#1336), cau

From: Peter Bex
Subject: [Chicken-hackers] [PATCH] Fix for "parameterize" regression (#1336), caused by fix for #1227
Date: Wed, 7 Dec 2016 22:43:40 +0100
User-agent: Mutt/1.5.23 (2014-03-12)

Hi all,

Joo ChurlSoo found another beaut, see #1336.  When we fixed #1227
(another bug found by Joo ChurlSoo), we broke the behaviour of
saving/restoration of parameters when entering/leaving the dynamic
extent of a "parameterize" form by using nonlocal exits/continuations.
Apparently nobody noticed this so far, but it's a pretty bad bug.

Instead of remembering each parameter's value at the point the extent
is left and restoring it when it is re-entered, we just reset the
parameter to its value as it was first set by the parameterize form
when it was entered.  This means that any subsequent modifications
made by calling the parameter procedure directly with a value are lost.

The attached patch fixes this by set!ting the saved values to the
current value when leaving the extent.

There's a second patch which ensures consistent behaviour between
compiled and interpreted code in the first example in #1336, which
would cause the compiled run of the library-tests to fail.

The current version of this code will return (a b c d c e d e e d)
in compiled mode and (a b c d b e d b e d) in interpreted mode on
that first example.

This is presumably due to the undefined evaluation order of LET,
which is nevertheless exposed by call/cc, but I have to say I
don't fully grok how this works.  But this can be fixed in the
second patch by wrapping the saved params in another let, so that
we get (let ((s1 v1) (s2 v2)) (let ((s1 s1) (s2 s2)) ...))
which ensures that if v1 or v2 is a side-effecting procedure, it
can't mess with the inner values that actually get set! by the
swapping code in the save/restore handler.

These patches apply to both master and chicken-5, and I think
the bug fix must go onto both branches in any case.


Attachment: 0001-Save-current-values-when-leaving-parameterizes.patch
Description: Text Data

Attachment: 0002-Remove-run-time-compile-time-diffs-in-parameterize.patch
Description: Text Data

Attachment: signature.asc
Description: Digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]