bugKawa - Bugs: bug #14072, inconsistent binding behavior for...

 
 

bug #14072: inconsistent binding behavior for threads

Submitter:  tk <huh>
Submitted:  Tue 09 Aug 2005 10:54:09 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  Unexpected result Status:  Invalid
Privacy:  Public Assigned to:  bothner
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 10 Aug 2005 07:12:45 AM UTC, comment #1: 

I don't think this is a bug.
The issue is how a thread inherits the evironment from a parent thread.  This is only supported when creating a Future.  Generalizing Environment inheritance for arbitrary threads is difficult.  The problem is how do you get the Environment of a parent thread?  Currently we use a ThreadLocal to map from the current thread to its CallContext and hence to its Environment, but you cannot get the ThreadLocal binding for any other thread.
It may be possible to use a a HashTable or similar to map a Thread to its Environment, and thus get the parent thread's Environment, but garbage collection makes this difficult.  (Using a WeakHashMap is an option, but only correct the Environemnt when the Thread is collected; not when the thread finishes.)
An API to allow the programmer to explicitly request that a child thread inherit it's parents Environment is desirable; you could submit a new "bug" as an enhancement request?

Per Bothner <bothner>
Group administrator
Tue 09 Aug 2005 10:54:09 PM UTC, original submission:  

not clear that this is a bug, but there's an inconsistency in the way
bindings are handled in environments created for a TelnetRepl or
scheme interaction window. (this is 1.8beta -- it wasn't an issue in 1.7)

following code works fine in a normal kawa interaction enviroment:

    $ rlwrap java -jar kawa-1.8beta.jar  
    #|kawa:1|# (set! x 'foo)
    #|kawa:2|# (invoke (object (<java.lang.Thread>) ((run) <void> (display x))) 'start)
    foo


but with the interaction environment in a TelnetRepl, the same code
running in the thread doesn't see the binding

    $ java -jar kawa-1.8beta.jar --server 2000
    Listening on port 2000
    waiting ... got connection from /127.0.0.1 port:61836
    waiting ... gnu.mapping.UnboundLocationException: unbound location x
    at gnu.mapping.Location.get(Location.java:67)
    at atInteractiveLevel$2$object.run(<stdin>:2)

    $ rlwrap nc localhost 2000
    #|kawa:1|# (set! x 'bar)
    #|kawa:2|# (invoke (object (<java.lang.Thread>) ((run) <void> (display x))) 'start)
    #|kawa:3|#

however, if the code in question is wrapped in a let that rebinds x, it works.
i haven't determined whether this is what i should expect, or if it's a hack
that just happens to work:

    #|kawa:4|# (let ((x x)) (invoke (object (<java.lang.Thread>) ((run) <void> (display x))) 'start))
    bar


tk <huh>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

Only logged-in users can vote.

 

Follow 4 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2005-08-10 bothner StatusNone Invalid
    Assigned toNone bothner
    Open/ClosedOpen Closed
2005-08-09 huh Carbon-Copy- Added -email is unavailable-

Back to the top

Powered by Savane 3.13-4b48.
Corresponding source code