buildStackTrace
Frank Mehnert
Frank.Mehnert at mchp.siemens.de
Thu Mar 13 07:48:45 PST 1997
Hi kaffe programmers,
while working on Chorus port of kaffe I havn't understand the working of
buildStackTrace yet. My port works with native threads on a single
processor. In exceptions I get different outputs between kaffe/Solaris and
kaffe/Chorus (kaffe 0.8.2/interpreter). Look at the following short
program (from the test package of kaffe):
=== listing === listing ===
public class T3 extends Thread {
String name;
long counter, delay;
public T3 ( String name, long delay, int priority ) {
this.name=name;
this.delay=delay;
setPriority(priority);
start();
}
public void run () {
while (true) {
if ( (++counter % 100) == 0 ){
System.out.println( name + " : " + counter);
try { Thread.sleep( delay ); }
catch ( Exception x ) { x.printStackTrace(); }
}
}
}
public static void main ( String[] args ) {
T3 a, b, c;
a = new T3( "A", 500, Thread.NORM_PRIORITY);
b = new T3( " B", 200, Thread.MIN_PRIORITY);
c = new T3( " C", 100, Thread.MIN_PRIORITY);
try { sleep(3000); }
catch ( Exception e ) { e.printStackTrace(); }
System.out.println("killing threads...");
a.stop();
b.stop();
try { sleep(1000); }
catch ( Exception e ) { e.printStackTrace(); }
a.destroy();
b.destroy();
c.destroy();
}
}
=== listing === listing ===
This program creates three threads and kills them dirty after a while.
With kaffe/Solaris I get the output
...
java.lang.NoSuchMethodError
at java/lang/Throwable.<init>(line unknown, pc 5)
at java/lang/Error.<init>(line unknown, pc 1)
at java/lang/LinkageError.<init>(line unknown, pc 1)
at java/lang/IncompatibleClassChangeError.<init>(line unknown, pc 1)
at java/lang/NoSuchMethodError.<init>(line unknown, pc 1)
at java/lang/Thread.destroy(line unknown, pc 4)
at T3.run(16)
but with kaffe/Chorus I get
...
java.lang.NoSuchMethodError
at java/lang/Throwable.<init>(line unknown, pc 0x5)
at java/lang/Error.<init>(line unknown, pc 0x1)
at java/lang/LinkageError.<init>(line unknown, pc 0x1)
at java/lang/IncompatibleClassChangeError.<init>(line unknown, pc 0x1)
at java/lang/NoSuchMethodError.<init>(line unknown, pc 0x1)
at java/lang/Thread.destroy(line unknown, pc 0x4)
at T3.run(16)
at T3.run(16)
at T3.run(16)
at T3.main(38)
If I create four threads, I get four times T3.run(16). Then I think
in several times this buildStackTrace dont work correctly (seg fault),
possibly because the stack may be different from kaffe with internal
threads.
The main reason, I think, is that I not playing with the cjbuf. In
kaffe/kaffevm/thread.c there are the lines
#if defined(INTERPRETER)
TCTX(currentThread)->exceptPtr = (void*)cjbuf;
cjbuf = 0;
#endif
lastThread = currentThread;
currentThread = threadQhead[i];
THREADSWITCH(TCTX(currentThread), TCTX(lastThread));
#if defined(INTERPRETER)
cjbuf = (vmException*)TCTX(lastThread)->exceptPtr;
#endif
Because native threads, I can't do something like that.
(Sorry for the long question, I hope you will understand my problem.)
Thanks in advance (also for the previos answers!)
Frank
PS: Tim, NullPointerExceptions become seg faults because you havn't
set HAVE_NULLPOINTER_TRAP in kaffe.def. This you made for
performance reasons, isn't it so?
Frank Mehnert
email: Frank.Mehnert at mchp.siemens.de
More information about the kaffe
mailing list