[kaffe] kaffe fails to handle AttachCurrentThread properly

Robert Schuster theBohemian at gmx.net
Wed Jan 23 07:59:27 PST 2008


Robert Schuster schrieb:
> Hi,
> I haven't looked deeply into this but kaffe
Now I did. Have a look at this gdb log.

Breakpoint 2, threadMain (arg=0x0) at Test.c:42
42	  JNIEnv* env = NULL;
(gdb) s

43	  (*cachedJavaVM)->AttachCurrentThread(cachedJavaVM, (void **) &env,
NULL);
(gdb) s
Kaffe_AttachCurrentThread (vm=0xb7f19c80, penv=0xb718a3d0, args=0x0)
    at ../../../kaffe/kaffe/kaffevm/jni/jni.c:773

773		if (KTHREAD(attach_current_thread) (false)) {
(gdb) s
jthread_attach_current_thread (isDaemon=false)
    at
../../../../../kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:696

696	  if (jthread_current() != NULL)
(gdb) p jthread_current
$1 = {jthread_t (void)} 0xb7f013ac <jthread_current>
(gdb) s
jthread_current ()
    at
../../../../../kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:1790

1790	  if (!jthreadInitialized)
(gdb) p jthreadInitialized
$2 = 1 '\001'
(gdb) s

1793	    void* specific = pthread_getspecific(ntKey);
(gdb) n

1795	    if (specific != NULL)
(gdb) p specific

$3 = (void *) 0x0
(gdb) s
1798	      perror(NULL);

As you can see it thinks it can get a thread specific value out of it. I
saw the code doing this stuff in cacao and I think there is a call
missing that stores first whatever 'ntKey' should store.

AttachCurrentThread with pthreads and boehm is a bit broken in cacao,
too. I wanted to have a look at how kaffe does it. The interesting bit
is, how do you get the boehm GC to claim the stack of the attached thread.

Regards
Robert

My .gdbinit file:

handle SIGSEGV nostop noprint pass
handle SIGILL nostop noprint pass
handle SIGXCPU nostop noprint pass
handle SIGPWR nostop noprint pass
file /home/rob/classpath/INSTALL/kaffe/jre/bin/kaffe-bin
#file cacao
set args -Djava.library.path=. Test
set breakpoint pending on

# notice whether this happens
break threadMain

define hook-stop
  handle SIGSEGV stop print
end

define nosegf
  handle SIGSEGV nostop noprint pass
end



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
Url : http://kaffe.org/pipermail/kaffe/attachments/20080123/82c2484e/attachment-0001.pgp 


More information about the kaffe mailing list