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

 
 

bug #14072: inconsistent binding behavior for threads

Submitted by:  tk <huh>
Submitted on:  Tue 09 Aug 2005 10:54:09 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: Unexpected resultStatus: Invalid
Privacy: PublicAssigned to: Per Bothner <bothner>
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

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>
Project AdministratorIn charge of this item.
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 File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

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):

 

 

Follow 4 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Wed 10 Aug 2005 07:12:45 AM UTCbothnerStatusNone=>Invalid
  Assigned toNone=>bothner
  Open/ClosedOpen=>Closed
Tue 09 Aug 2005 10:54:09 PM UTChuhCarbon-Copy-=>Added -unavailable-

Back to the top


Powered by Savane 3.1-cleanup1