bugKawa - Bugs: bug #32294, Environment.setIndirectDefines...


bug #32294: Environment.setIndirectDefines broken

Submitted by:  tk <huh>
Submitted on:  Sat 29 Jan 2011 09:03:46 PM UTC  
Category: NoneSeverity: 3 - Normal
Item Group: Run-time exceptionStatus: None
Privacy: PublicAssigned to: None
Open/Closed: Open

Add a New Comment (Rich MarkupRich Markup):

You are not logged in

Please log in, so followups can be emailed to you.


Mon 16 May 2011 03:51:00 PM UTC, comment #2:

i'm cleaning up some of my local kawa hacks and noticed that
this fix has not gotten into the source trunk. does this need
a proper patch diff + changelog entry, or is there another
reason not to incorporate it?

tk <huh>
Tue 01 Feb 2011 06:40:20 AM UTC, comment #1:

The patch is probably ok, since it just comments out an optimization. I don't have a good feeling for how much difference the optimization makes. It seems like it should be possible to replace the optimization by one defer the optimization to lookupInherited: If the appropriate flags are set then we cam skip the lookup in the parent.

Per Bothner <bothner>
Project Administrator
Sat 29 Jan 2011 09:03:46 PM UTC, original submission:

using Environment.setIndirectDefines causes subsequent defines to
throw exceptions. [1.11 (revision 6892M)]

following transcript shows simple means of reproducing lossage,
and a couple of hints (perhaps) about where things are going wrong.
(I haven't yet determined a fix that I trust).

## $ kawa --server 3333

$ rlwrap nc localhost 3333
#|kawa:1|# (interaction-environment)
#<environment r0>

#|kawa:2|# (invoke (interaction-environment) 'getParent 0)
/dev/stdin:2:1: warning - no accessible method 'getParent' in gnu.mapping.Environment
#<environment language-builtins>

#|kawa:3|# (invoke (interaction-environment) 'setIndirectDefines)

#|kawa:4|# (define x 1)
Invalid parameter, was: gnu.expr.BuiltinEnvironment cannot be cast to gnu.mapping.SimpleEnvironment
java.lang.ClassCastException: gnu.expr.BuiltinEnvironment cannot be cast to gnu.mapping.SimpleEnvironment
at gnu.mapping.SimpleEnvironment.addLocation(SimpleEnvironment.java:204)
at gnu.mapping.SimpleEnvironment.addLocation(SimpleEnvironment.java:175)
at gnu.expr.ModuleExp.evalModule2(ModuleExp.java:329)
at gnu.expr.ModuleExp.evalModule(ModuleExp.java:188)
at kawa.Shell.run(Shell.java:284)
at kawa.Shell.run(Shell.java:197)
at kawa.Shell.run(Shell.java:178)
at kawa.TelnetRepl.apply0(TelnetRepl.java:23)
at gnu.mapping.RunnableClosure.run(RunnableClosure.java:78)
at gnu.mapping.Future.run(Future.java:44)


it was a little surprising that the repl's parent environment
was #<environment language-builtins> -- I'd have expected
the parent to be the TelnetRepl's environment.

I took a look at cloneForThread in gnu.mapping.Environment,
and did an experiment with commenting the following block
of code at the beginning of the method. I don't claim
that this is a fix by any means...not sure what's going
on here....but this change allows setIndirectDefines
to (appear to) work correctly

SimpleEnvironment cloneForThread ()
InheritingEnvironment env = new InheritingEnvironment(null, this);

// There is no point for a lookup to search this Environment,
// since its bindings will be cloned. Instead patch the new Environment
// so it inherits from its grandparents instead.
if (this instanceof InheritingEnvironment)
InheritingEnvironment p = (InheritingEnvironment) this;
int numInherited = p.numInherited;
env.numInherited = numInherited;
env.inherited = new Environment[numInherited];
for (int i = 0; i < numInherited; i++)
env.inherited[i] = p.inherited[i];

$ rlwrap nc localhost 3333
#|kawa:1|# (interaction-environment)
#<environment r0>

#|kawa:2|# (invoke (interaction-environment) 'getParent 0)
/dev/stdin:2:1: warning - no accessible method 'getParent' in gnu.mapping.Environment
#<environment main>

#|kawa:3|# (invoke (interaction-environment) 'setIndirectDefines)

#|kawa:4|# (define x 1)

$ rlwrap nc localhost 3333
#|kawa:1|# x

### this is the expected result...definition of x is shared across repls

tk <huh>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by bothner (Posted a comment)
  • -unavailable- added by huh (Submitted the item)
  • -unavailable- added by huh

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follows 1 latest change.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 29 Jan 2011 09:03:46 PM UTChuhCarbon-Copy-=>Added -unavailable-

    Back to the top

    Powered by Savane 3.1-cleanup