Why does this program cause an NPE in LibgcjInternalFinalizerThread ??

David Daney ddaney@avtrex.com
Tue Aug 19 22:55:00 GMT 2003


Tom Tromey wrote:
>>>>>>"David" == David Daney <ddaney@avtrex.com> writes:
>>>>>>>>>>>>>>David> I am still trying to find the cause of a problem I am having.
>David> This program seems to make libgcj unhappy.
>>David> System configuration linux x86 (RedHat 7.1) w/ kernel 2.4.20
>David> and gcj 3.3.1
>>I tried this on x86 Red Hat Linux 9, using the current trunk gcj.
>>Mostly it seems to hang, occasionally it works fine.
>>gdb isn't being much help; can't get a backtrace.
>>Tom
>new program:
We get similar behavior (perhaps identical) with our mipsel-linux-gcj. 
 It is the same problem I posted several days ago.
Using a massivly instrumented version of natReference.cc I think that 
what is happening is this:
The object_list.reference is pointing to either a WeakReference or a 
SoftReference. At some as yet unknown point it points something other 
than one of these, causing a crash usually when ref->enqueue() is called 
because the vtable of the object is not a Reference vtable.
I added checksum and magic fields to object_list, and check the 
integrity of the hash structure before and after each operation. 
 Although I am not positive, I think that the hash structure is not 
changing. My current thought is that the WeakReference is being GCed 
and its space is then given to a new object (probably a String with this 
test program) and now the object_list.reference pointer is pointing to 
the new object rather than the WeakReference.
I have not duplicated my tests with an x86 build, but since the behavior 
is (close to) identical, it seems plausable that the cause is the same.
Dave.
new program:
-----------------------------------------
import java.lang.ref.*;
public class Reftest {
 public void run(int id)
 {
 Reference r;
 for (int i=0; i<10000; i++) {
 r = new SoftReference("SoftReference Id "+id + ' ' + i);
 r = new WeakReference("WeakReference Id "+id + ' ' + i);
 // Different mod values cause either good or bad operation
 // 250 seems to be bad, 200 seems to be good.
 if(0 == i% 250) {
 System.out.println("Id: " + id + " i = " + i);
 System.gc();
 System.runFinalization();
 System.gc();
 System.runFinalization();
 }
 }
 System.out.println("iteration "+id+" finishing");
 }
 public Reftest() {
 }
 public static void main(String[] args) {
 System.setProperty("gnu.gcj.runtime.NameFinder.use_addr2line", 
"false");
 System.setProperty("gnu.gcj.runtime.NameFinder.sanitize", "false");
 System.setProperty("gnu.gcj.runtime.NameFinder.remove_unknown", 
"false");
 for (int i = 0; i<20; i++) {
 Reftest reftest1 = new Reftest();
 reftest1.run(i+1);
 }
 }
}
--------------------------------------------------------------
>>


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /