Problem in 3.0.1?

Martin Kahlert martin.kahlert@infineon.com
Thu Jul 26 02:03:00 GMT 2001


Hi!

I assume there is a problem in the 20010716 snapshot:
My app runs successfully to end, but then it aborts.
I tried to produce a smaller testcase but did not succeed.
The main app is linked with libefence and (up to now) successfully uses JNI
but not its invocation API.

This is the stack trace:
#0  0x400208f2 in memalign () from /usr/lib/libefence.so.0
#1  0x40020e76 in malloc () from /usr/lib/libefence.so.0
#2  0x40154ca2 in _Jv_Malloc (size=4) at ../../../libjava/prims.cc:960
#3  0x4016dd70 in _Jv_PrepareConstantTimeTables(java::lang::Class*) (klass=0x40316fc0) at ../../../libjava/java/lang/natClass.cc:1060
#4  0x4016d468 in java::lang::Class::initializeClass() (this=0x40316fc0) at ../../../libjava/java/lang/natClass.cc:704
#5  0x40285e8b in _Jv_InitClass (klass=0x40316fc0) at ../../../libjava/java/lang/Class.h:256
#6  0x401e11ff in gnu.gcj.runtime.FileDeleter.deleteOnExitNow() () at ../../../libjava/gnu/gcj/runtime/FileDeleter.java:27
#7  0x401715d3 in java::lang::Runtime::_exit(int) (this=0x89b5e40, status=0) at ../../../libjava/java/lang/natRuntime.cc:95
#8  0x40154a36 in JvRunMain (klass=0x86619a0, argc=3, argv=0xbffff2c4) at ../../../libjava/prims.cc:863
#9  0x081c7163 in main ()
#10 0x4049da4e in __libc_start_main (main=0x81c7140 <main>, argc=3, argv=0xbffff2c4, init=0x81c5640 <_init>, fini=0x8590530 <_fini>, 
    rtld_fini=0x4000aa20 <_dl_fini>, stack_end=0xbffff2bc) at ../sysdeps/generic/libc-start.c:92

Any ideas, where this could come from?
I assume, it tries to initialize FileDeleter::deleteOnExitStack in order to check if it is null
or something like that.

Thanks in advance
Martin.


PS: I use the following patches to make my app work at all.
    Since this week there was no snapshot, i do not know wether
    any of these patches is already included in 3.0.1.

2001-07-13  Martin Kahlert  <martin.kahlert@infineon.com>

	*  java/lang/natClass.cc: Move calls of _Jv_InitClass from
	java::lang::Class::isAssignableFrom and java::lang::Class::isInstance
	into _Jv_IsAssignableFrom

2001-05-09  Martin Kahlert  <martin.kahlert@infineon.com>

	* jni.cc (_Jv_JNI_NewLocalRef): Search next frame, if
	we could not find free slot in this one. Fixes infinite loop.

2001-05-04  Martin Kahlert  <martin.kahlert@infineon.com>

	* prims.cc (JvRunMain): Make sure, that runtime has been
	initialized before main_thread is started

2001-05-03  Tom Tromey  <tromey@redhat.com>

	* java/lang/natRuntime.cc (init): Call add_library on the program
	itself.
	(_Jv_FindSymbolInExecutable): Return NULL if no library on the
	list has the symbol.

diff -rc gcc-20010716.orig/libjava/java/lang/natClass.cc gcc-20010716/libjava/java/lang/natClass.cc
*** gcc-20010716.orig/libjava/java/lang/natClass.cc	Tue Jun  5 11:56:10 2001
--- gcc-20010716/libjava/java/lang/natClass.cc	Tue Jul 17 12:38:04 2001
***************
*** 624,632 ****
  jboolean
  java::lang::Class::isAssignableFrom (jclass klass)
  {
-   // Arguments may not have been initialized, given ".class" syntax.
-   _Jv_InitClass (this);
-   _Jv_InitClass (klass);
    return _Jv_IsAssignableFrom (this, klass);
  }
  
--- 624,629 ----
***************
*** 635,641 ****
  {
    if (! obj)
      return false;
-   _Jv_InitClass (this);
    return _Jv_IsAssignableFrom (this, JV_CLASS (obj));
  }
  
--- 632,637 ----
***************
*** 909,914 ****
--- 905,914 ----
  jboolean
  _Jv_IsAssignableFrom (jclass target, jclass source)
  {
+   // Arguments may not have been initialized, given ".class" syntax.
+   _Jv_InitClass (target);
+   _Jv_InitClass (source);
+ 
    if (source == target)
      return true;
       
diff -rc gcc-20010716.orig/libjava/java/lang/natRuntime.cc gcc-20010716/libjava/java/lang/natRuntime.cc
*** gcc-20010716.orig/libjava/java/lang/natRuntime.cc	Mon Mar 12 08:33:57 2001
--- gcc-20010716/libjava/java/lang/natRuntime.cc	Tue Jul 17 12:38:04 2001
***************
*** 69,75 ****
  	return r;
      }
  
!   return lt_dlsym (NULL, symname);
  }
  
  #endif /* USE_LTDL */
--- 69,75 ----
  	return r;
      }
  
!   return NULL;
  }
  
  #endif /* USE_LTDL */
***************
*** 191,196 ****
--- 191,199 ----
    finalize_on_exit = false;
  #ifdef USE_LTDL
    lt_dlinit ();
+   lt_dlhandle self = lt_dlopen (NULL);
+   if (self != NULL)
+     add_library (self);
  #endif
  }
  
diff -rc gcc-20010716.orig/libjava/jni.cc gcc-20010716/libjava/jni.cc
*** gcc-20010716.orig/libjava/jni.cc	Thu May  3 18:55:34 2001
--- gcc-20010716/libjava/jni.cc	Tue Jul 17 12:38:04 2001
***************
*** 281,296 ****
    // Try to find an open slot somewhere in the topmost frame.
    _Jv_JNI_LocalFrame *frame = env->locals;
    bool done = false, set = false;
!   while (frame != NULL && ! done)
      {
        for (int i = 0; i < frame->size; ++i)
! 	if (frame->vec[i] == NULL)
! 	  {
! 	    set = true;
! 	    done = true;
! 	    frame->vec[i] = obj;
! 	    break;
! 	  }
      }
  
    if (! set)
--- 281,303 ----
    // Try to find an open slot somewhere in the topmost frame.
    _Jv_JNI_LocalFrame *frame = env->locals;
    bool done = false, set = false;
!   for (; frame != NULL && ! done; frame = frame->next)
      {
        for (int i = 0; i < frame->size; ++i)
!         {
!           if (frame->vec[i] == NULL)
!             {
!               set = true;
!               done = true;
!               frame->vec[i] = obj;
!               break;
!             }
!         }
!  
!        // If we found a slot, or if the frame we just searched is the
!        // mark frame, then we are done.
!        if (done || frame->marker != MARK_NONE)
!         break;
      }
  
    if (! set)
diff -rc gcc-20010716.orig/libjava/prims.cc gcc-20010716/libjava/prims.cc
*** gcc-20010716.orig/libjava/prims.cc	Sun May 20 18:24:40 2001
--- gcc-20010716/libjava/prims.cc	Tue Jul 17 12:38:04 2001
***************
*** 849,860 ****
    arg_vec = JvConvertArgv (argc - 1, argv + 1);
    main_thread = new gnu::gcj::runtime::FirstThread (klass, arg_vec);
  
    main_thread->start();
    _Jv_ThreadWait ();
  
    int status = (int) java::lang::ThreadGroup::had_uncaught_exception;
!     
!   java::lang::Runtime::getRuntime ()->_exit (status);
  }
  
  void
--- 849,866 ----
    arg_vec = JvConvertArgv (argc - 1, argv + 1);
    main_thread = new gnu::gcj::runtime::FirstThread (klass, arg_vec);
  
+   /* Initialize Runtime before we start the main_thread.
+    *     * This ensures, that the libraries are initialized even
+    *     * if the main class contains native JNI methods, which were 
+    *     * statically linked into the executable */
+   java::lang::Runtime *rt = java::lang::Runtime::getRuntime ();
+ 
    main_thread->start();
    _Jv_ThreadWait ();
  
    int status = (int) java::lang::ThreadGroup::had_uncaught_exception;
! 
!   rt->_exit (status);
  }
  
  void


-- 
The early bird catches the worm. If you want something else for       
breakfast, get up later.



More information about the Java mailing list