[Tcl Java] [Tcl Java] Tcl Blend + java::bind problem, could you help test?

2000-01-31 Thread Mo DeJong

Hello all.

This is just an update on the java::bind dead-locking problems
that I have run into on the Linux port of Blackdown JDK 1.1.7.
It seems that Java threads are getting dead-locked when calling
back Tcl code created by a java::bind command. I tried the
example on Windows, and there were no problems. I then tried
it with the IBM JDK 118 port for Linux and Sun's JDK on
Solaris. There were no problems with deadlocking on
those systems so this must be a JVM bug in the blackdown
JDK. I am going to add this example as a test case
and add a note to the known_issues.txt file, but because this
is a JVM bug there is nothing I can do to fix it.

Mo Dejong
Red Hat Inc.


The TclJava mailing list is sponsored by Scriptics Corporation.
To subscribe:send mail to [EMAIL PROTECTED]  
 with the word SUBSCRIBE as the subject.
To unsubscribe:  send mail to [EMAIL PROTECTED] 
 with the word UNSUBSCRIBE as the subject.
To send to the list, send email to '[EMAIL PROTECTED]'. 
An archive is available at http://www.mail-archive.com/tcljava@scriptics.com



[Tcl Java] Tcl Blend + java::bind problem, could you help test?

2000-01-19 Thread Mo DeJong

Hi all.

I seem to have run into a really big problem with the java::bind
command that I need some help with. The problem only seems to
show up in Tcl Blend, and I have only tested it on my RedHat 5.2
Linux box thus far. Could people on the list try out this example
and post the results they get? The problem seems to be that when
another Java thread invokes a callback created with the java::bind
command, the Tcl callback never gets invoked and the other thread
gets deadlocked. This same code works just fine in Jacl.

Mo Dejong
Red Hat Inc.



// Start of file Bind.java

// This class implements a bindable object that will
// generate an event to a tcljava binding (java::bind)

import java.util.EventObject;
import java.util.EventListener;

public class Bind implements Runnable {
ActionListener actionListener = null;
Thread t = null;
boolean started;
boolean stopped;
int tnum = 0;

final boolean debug = true;

public void addActionListener(ActionListener l) {
actionListener = l;
}

public void removeActionListener(ActionListener l) {
actionListener = null;
}

public void doLater() {
// Create new thread that will invoke the call to
// actionListener.actionPerformed(ActionEvent)
// in another thread at a later time

started = false;
stopped = false;

tnum++;
t = new Thread(this);
t.setDaemon(true);
t.setName("Bind delay thread " + tnum);
t.start();

if (debug) {
System.err.println("Waiting to invoke action");
}
}

public void run() {
started = true;

// Go to sleep for some time
try {
Thread.sleep(3000);
}
catch (InterruptedException ie) {}

if (debug) {
System.err.println("Now to invoke action");
}

// Now invoke the callback (from a different thread)
actionListener.actionPerformed(new ActionEvent(this));

stopped = true;
t = null;
}

public boolean wasStarted() {
return started;
}

public boolean wasStopped() {
return stopped;
}
}


interface ActionListener extends EventListener {
public void actionPerformed(ActionEvent e);
}

class ActionEvent extends EventObject {
ActionEvent(Object source) {
super(source);
}
}

// End of file Bind.java




# Tcl code from this bind class
# Be sure to run "javac Bind.java" first


package require java
set env(TCL_CLASSPATH) .

set b [java::new Bind]

set action 0

java::bind $b actionPerformed {
set action 1
puts "Hi there"
#error NO
}

$b doLater


# Wait a little while and see what happened
after 4000 {

if {[$b wasStarted]} {
  puts "Thread Was Started"
}

if {! [$b wasStopped]} {
  puts "Thread Is Deadlocked"
}

if {! $action} {
  puts "No Action Taken"
}

}








Results on Linux:

Jacl under JDK 1.1 from Blackdown:
Works

Tcl Blend under JDK 1.1 from Blackdown:
Hangs, call to Tcl event never made

Same seems to apply for JDK 1.2.




Here is the thread dump from Tcl Blend when the Java thread
is blocked.


Full thread dump:
"Bind delay thread" (TID:0x405ba390, sys_thread_t:0x807b178, state:CW, thread_t: 
t@4100, sp:0xbf3ff840 threadID:0xef1, stack_base:0xbf3ffd68, stack_size:0x20) 
prio=5
tcl.lang.TclEvent.sync(TclEvent.java:126)
tcl.lang.EventAdaptor._processEvent(EventAdaptor.java:334)
tcl.lang.Adaptor0.actionPerformed(Unknown Source)
Bind.run(Bind.java:91)
java.lang.Thread.run(Thread.java)
"SIGQUIT handler" (TID:0x405b32a0, sys_thread_t:0x80cdc80, state:R, thread_t: 
t@3075, sp:0xbf5ff40c threadID:0xef0, stack_base:0xbf5ffd68, stack_size:0x20) 
prio=0 *current thread*
"Finalizer thread" (TID:0x405b3088, sys_thread_t:0x80cdb60, state:CW, thread_t: 
t@2050, sp:0xbf7ff984 threadID:0xeef, stack_base:0xbf7ffd68, stack_size:0x20) 
prio=1
"main" (TID:0x405b30b0, sys_thread_t:0x80cd2d8, state:R, thread_t: t@1024, 
sp:0xbfffef30 threadID:0xeec, stack_base:0x0, stack_size:0x20) prio=5
Monitor Cache Dump:
tcl.lang.BeanEvent@1079747800/1080198008: unowned
Waiting to be notified:
"Bind delay thread" (0x807b178)
java.lang.Class@1079734352/1080109664: owner "main" (0x80cd2d8, 1 entry)





The TclJava mailing list is sponsored by Scriptics Corporation.
To subscribe:send mail to [EMAIL PROTECTED]  
 with the word SUBSCRIBE as the subject.
To unsubscribe:  send mail to [EMAIL PROTECTED] 
 with the word UNSUBSCRIBE as the subject.
To send to the list, send email to '[EMAIL PROTECTED]'. 
An archive is available at http://www.mail-archive.com/tcljava@scriptics.com