Request for review (XS): JDK-8006641: JDK-8003985 broke InstanceKlass.getFieldOffset() in SA

Krystal Mo krystal.mo at oracle.com
Mon Jan 21 10:43:22 PST 2013


Hi all,

Could someone review this small patch, please?
JDK-8006641: JDK-8003985 broke InstanceKlass.getFieldOffset() in SA

Webrev: http://cr.openjdk.java.net/~kmo/8006641/webrev.00/

Bug: https://jbs.oracle.com/bugs/browse/JDK-8006641
(public bug will be available soon at: 
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8006641)

Description: JDK-8003985 introduced "packed offsets" in InstanceKlass' 
fields array, so code accessing field offset in InstanceKlass was 
changed accordingly. But the change in the SA part mistakenly used 
FIELDINFO_TAG_SIZE instead of FIELDINFO_TAG_MASK for masking in 
InstanceKlass.getFieldOffset(), which broke a couple of utils in SA, 
e.g. PStack

This change aligns the SA code back in sync with the VM code for 
InstanceKlass.getFieldOffset().

Tested with a simple test case that would fail before the fix.

Thanks,
Kris

(The scenario I tested with is described below)

I was trying to hunt down a 292 bug and when I used the pstack command 
in clhsdb, I got:

hsdb> pstack -v
Error: java.lang.RuntimeException: should not reach here
java.lang.RuntimeException: should not reach here
     at 
sun.jvm.hotspot.oops.InstanceKlass.getFieldOffset(InstanceKlass.java:327)
     at sun.jvm.hotspot.oops.Field.<init>(Field.java:47)
     at sun.jvm.hotspot.oops.OopField.<init>(OopField.java:42)
     at sun.jvm.hotspot.oops.NarrowOopField.<init>(NarrowOopField.java:40)
     at sun.jvm.hotspot.oops.InstanceKlass.newField(InstanceKlass.java:913)
     at 
sun.jvm.hotspot.oops.InstanceKlass.findLocalField(InstanceKlass.java:628)
     at sun.jvm.hotspot.oops.InstanceKlass.findField(InstanceKlass.java:665)
     at sun.jvm.hotspot.oops.InstanceKlass.findField(InstanceKlass.java:689)
     at 
sun.jvm.hotspot.oops.OopUtilities.initAbsOwnSyncFields(OopUtilities.java:305)
     at 
sun.jvm.hotspot.oops.OopUtilities.abstractOwnableSynchronizerGetOwnerThread(OopUtilities.java:312)
     at 
sun.jvm.hotspot.runtime.ConcurrentLocksPrinter.getOwnerThread(ConcurrentLocksPrinter.java:55)
     at 
sun.jvm.hotspot.runtime.ConcurrentLocksPrinter.access$000(ConcurrentLocksPrinter.java:32)
     at 
sun.jvm.hotspot.runtime.ConcurrentLocksPrinter$1.doObj(ConcurrentLocksPrinter.java:72)
     at 
sun.jvm.hotspot.oops.ObjectHeap.iterateLiveRegions(ObjectHeap.java:354)
     at sun.jvm.hotspot.oops.ObjectHeap.iterateSubtypes(ObjectHeap.java:287)
     at 
sun.jvm.hotspot.oops.ObjectHeap.iterateObjectsOfKlass(ObjectHeap.java:187)
     at 
sun.jvm.hotspot.runtime.ConcurrentLocksPrinter.fillLocks(ConcurrentLocksPrinter.java:70)
     at 
sun.jvm.hotspot.runtime.ConcurrentLocksPrinter.<init>(ConcurrentLocksPrinter.java:36)
     at sun.jvm.hotspot.tools.PStack.run(PStack.java:68)
     at sun.jvm.hotspot.tools.PStack.run(PStack.java:57)
     at sun.jvm.hotspot.CommandProcessor$31.doit(CommandProcessor.java:1084)
     at 
sun.jvm.hotspot.CommandProcessor.executeCommand(CommandProcessor.java:1897)
     at 
sun.jvm.hotspot.CommandProcessor.executeCommand(CommandProcessor.java:1867)
     at sun.jvm.hotspot.CommandProcessor.run(CommandProcessor.java:1747)
     at sun.jvm.hotspot.CLHSDB.run(CLHSDB.java:91)
     at sun.jvm.hotspot.CLHSDB.main(CLHSDB.java:35)

Which led me to finding this bug. After the fix, the pstack command ran 
fine again:

hsdb> pstack -v
Deadlock Detection:

No deadlocks found.

----------------- 10912 -----------------
0x00007fc87d037d84    __pthread_cond_wait + 0xc4
0x00007fc87beb9657    _ZN7Monitor5IWaitEP6Threadl + 0x127
0x00007fc87bebbaf9    _ZN7Monitor4waitEblb + 0x319
0x00007fc87b951467    _ZN12CompileQueue3getEv + 0x107
0x00007fc87b957074    _ZN13CompileBroker20compiler_thread_loopEv + 0x274
0x00007fc87c11ce6e    _ZN10JavaThread17thread_main_innerEv + 0x18e
0x00007fc87c11d0ef    _ZN10JavaThread3runEv + 0x23f
0x00007fc87bf154c2    _ZL10java_startP6Thread + 0x132
Locked ownable synchronizers:
     - None
----------------- 10914 -----------------
0x00007fc87d0380fe    __pthread_cond_timedwait + 0x13e
0x00007fc87beb9a87    _ZN7Monitor5IWaitEP6Threadl + 0x557
0x00007fc87bebb93c    _ZN7Monitor4waitEblb + 0x15c
0x00007fc87c1105e3    _ZNK13WatcherThread5sleepEv + 0x73
0x00007fc87c110755    _ZN13WatcherThread3runEv + 0xd5
0x00007fc87bf154c2    _ZL10java_startP6Thread + 0x132
----------------- 10909 -----------------
0x00007fc87d039fd0    sem_wait + 0x30
0x00007fc87bf11cb9    _ZL19signal_thread_entryP10JavaThreadP6Thread + 0x59
0x00007fc87c11ce6e    _ZN10JavaThread17thread_main_innerEv + 0x18e
0x00007fc87c11d0ef    _ZN10JavaThread3runEv + 0x23f
0x00007fc87bf154c2    _ZL10java_startP6Thread + 0x132
Locked ownable synchronizers:
     - None
----------------- 10906 -----------------
0x00007fc87d0380fe    __pthread_cond_timedwait + 0x13e
0x00007fc87beb9a87    _ZN7Monitor5IWaitEP6Threadl + 0x557
0x00007fc87bebb93c    _ZN7Monitor4waitEblb + 0x15c
0x00007fc87c1b0960    _ZN8VMThread4loopEv + 0x3f0
0x00007fc87c1b0db1    _ZN8VMThread3runEv + 0xb1
0x00007fc87bf154c2    _ZL10java_startP6Thread + 0x132
----------------- 10908 -----------------
0x00007fc87d037d84    __pthread_cond_wait + 0xc4
0x00007fc87befcae5    _ZN13ObjectMonitor4waitElbP6Thread + 0xb75
0x00007fc87bc72db0    JVM_MonitorWait + 0x1b0
0x00007fc86e023d42    * java.lang.Object.wait(long) bci:0 
Method*:0x00007fc879793c60 (Interpreted frame)
0x00007fc86e006278    * java.lang.ref.ReferenceQueue.remove(long) bci:44 
line:135 Method*:0x00007fc87984b1e0 (Interpreted frame)
0x00007fc86e006453    * java.lang.ref.ReferenceQueue.remove() bci:2 
line:151 Method*:0x00007fc87984b2b0 (Interpreted frame)
0x00007fc86e006453    * java.lang.ref.Finalizer$FinalizerThread.run() 
bci:3 line:177 Method*:0x00007fc87984c210 (Interpreted frame)
0x00007fc86e000681    <StubRoutines>
0x00007fc87bbef138 
_ZN9JavaCalls11call_helperEP9JavaValueP12methodHandleP17JavaCallArgumentsP6Thread 
+ 0x1b18
0x00007fc87bbeb64f 
_ZN9JavaCalls12call_virtualEP9JavaValue11KlassHandleP6SymbolS4_P17JavaCallArgumentsP6Thread 
+ 0x5cf
0x00007fc87bbebe7a 
_ZN9JavaCalls12call_virtualEP9JavaValue6Handle11KlassHandleP6SymbolS5_P6Thread 
+ 0x5a
0x00007fc87bc6f92e    _ZL12thread_entryP10JavaThreadP6Thread + 0x7e
0x00007fc87c11ce6e    _ZN10JavaThread17thread_main_innerEv + 0x18e
0x00007fc87c11d0ef    _ZN10JavaThread3runEv + 0x23f
0x00007fc87bf154c2    _ZL10java_startP6Thread + 0x132
Locked ownable synchronizers:
     - None
----------------- 10910 -----------------
0x00007fc87d037d84    __pthread_cond_wait + 0xc4
0x00007fc87beb9657    _ZN7Monitor5IWaitEP6Threadl + 0x127
0x00007fc87bebbaf9    _ZN7Monitor4waitEblb + 0x319
0x00007fc87b951467    _ZN12CompileQueue3getEv + 0x107
0x00007fc87b957074    _ZN13CompileBroker20compiler_thread_loopEv + 0x274
0x00007fc87c11ce6e    _ZN10JavaThread17thread_main_innerEv + 0x18e
0x00007fc87c11d0ef    _ZN10JavaThread3runEv + 0x23f
0x00007fc87bf154c2    _ZL10java_startP6Thread + 0x132
Locked ownable synchronizers:
     - None
----------------- 10911 -----------------
0x00007fc87d037d84    __pthread_cond_wait + 0xc4
0x00007fc87beb9657    _ZN7Monitor5IWaitEP6Threadl + 0x127
0x00007fc87bebbaf9    _ZN7Monitor4waitEblb + 0x319
0x00007fc87b951467    _ZN12CompileQueue3getEv + 0x107
0x00007fc87b957074    _ZN13CompileBroker20compiler_thread_loopEv + 0x274
0x00007fc87c11ce6e    _ZN10JavaThread17thread_main_innerEv + 0x18e
0x00007fc87c11d0ef    _ZN10JavaThread3runEv + 0x23f
0x00007fc87bf154c2    _ZL10java_startP6Thread + 0x132
Locked ownable synchronizers:
     - None
----------------- 10907 -----------------
0x00007fc87d037d84    __pthread_cond_wait + 0xc4
0x00007fc87befcae5    _ZN13ObjectMonitor4waitElbP6Thread + 0xb75
0x00007fc87bc72db0    JVM_MonitorWait + 0x1b0
0x00007fc86e023d42    * java.lang.Object.wait(long) bci:0 
Method*:0x00007fc879793c60 (Interpreted frame)
0x00007fc86e006278    * java.lang.Object.wait() bci:2 line:502 
Method*:0x00007fc879793e50 (Interpreted frame)
0x00007fc86e006278    * java.lang.ref.Reference$ReferenceHandler.run() 
bci:36 line:142 Method*:0x00007fc87984a5d0 (Interpreted frame)
0x00007fc86e000681    <StubRoutines>
0x00007fc87bbef138 
_ZN9JavaCalls11call_helperEP9JavaValueP12methodHandleP17JavaCallArgumentsP6Thread 
+ 0x1b18
0x00007fc87bbeb64f 
_ZN9JavaCalls12call_virtualEP9JavaValue11KlassHandleP6SymbolS4_P17JavaCallArgumentsP6Thread 
+ 0x5cf
0x00007fc87bbebe7a 
_ZN9JavaCalls12call_virtualEP9JavaValue6Handle11KlassHandleP6SymbolS5_P6Thread 
+ 0x5a
0x00007fc87bc6f92e    _ZL12thread_entryP10JavaThreadP6Thread + 0x7e
0x00007fc87c11ce6e    _ZN10JavaThread17thread_main_innerEv + 0x18e
0x00007fc87c11d0ef    _ZN10JavaThread3runEv + 0x23f
0x00007fc87bf154c2    _ZL10java_startP6Thread + 0x132
Locked ownable synchronizers:
     - None
----------------- 10905 -----------------
0x00007fc87d037d84    __pthread_cond_wait + 0xc4
0x00007fc87beb9657    _ZN7Monitor5IWaitEP6Threadl + 0x127
0x00007fc87bebb93c    _ZN7Monitor4waitEblb + 0x15c
0x00007fc87bae7eb2    _ZN13GCTaskManager8get_taskEj + 0x72
0x00007fc87baeab5f    _ZN12GCTaskThread3runEv + 0x25f
0x00007fc87bf154c2    _ZL10java_startP6Thread + 0x132
----------------- 10904 -----------------
0x00007fc87d037d84    __pthread_cond_wait + 0xc4
0x00007fc87beb9657    _ZN7Monitor5IWaitEP6Threadl + 0x127
0x00007fc87bebb93c    _ZN7Monitor4waitEblb + 0x15c
0x00007fc87bae7eb2    _ZN13GCTaskManager8get_taskEj + 0x72
0x00007fc87baeab5f    _ZN12GCTaskThread3runEv + 0x25f
0x00007fc87bf154c2    _ZL10java_startP6Thread + 0x132
----------------- 10900 -----------------
0x00007fc87d035148    pthread_join + 0xb8
0x00007fc87d448700        ????????
0x00007fc87ce1b63a    ContinueInNewThread + 0x7a
0x00007fc87ce1e240    JLI_Launch + 0x480
0x00000000004006d6    main + 0x76
----------------- 10903 -----------------
0x00007fc87d037d84    __pthread_cond_wait + 0xc4
0x00007fc87beb9657    _ZN7Monitor5IWaitEP6Threadl + 0x127
0x00007fc87bebb93c    _ZN7Monitor4waitEblb + 0x15c
0x00007fc87bae7eb2    _ZN13GCTaskManager8get_taskEj + 0x72
0x00007fc87baeab5f    _ZN12GCTaskThread3runEv + 0x25f
0x00007fc87bf154c2    _ZL10java_startP6Thread + 0x132
----------------- 10902 -----------------
0x00007fc87d037d84    __pthread_cond_wait + 0xc4
0x00007fc87beb9657    _ZN7Monitor5IWaitEP6Threadl + 0x127
0x00007fc87bebb93c    _ZN7Monitor4waitEblb + 0x15c
0x00007fc87bae7eb2    _ZN13GCTaskManager8get_taskEj + 0x72
0x00007fc87baeab5f    _ZN12GCTaskThread3runEv + 0x25f
0x00007fc87bf154c2    _ZL10java_startP6Thread + 0x132
----------------- 10913 -----------------
0x00007fc87d037d84    __pthread_cond_wait + 0xc4
0x00007fc87beb9657    _ZN7Monitor5IWaitEP6Threadl + 0x127
0x00007fc87bebb93c    _ZN7Monitor4waitEblb + 0x15c
0x00007fc87c021ba5 
_ZN13ServiceThread20service_thread_entryEP10JavaThreadP6Thread + 0x275
0x00007fc87c11ce6e    _ZN10JavaThread17thread_main_innerEv + 0x18e
0x00007fc87c11d0ef    _ZN10JavaThread3runEv + 0x23f
0x00007fc87bf154c2    _ZL10java_startP6Thread + 0x132
Locked ownable synchronizers:
     - None
----------------- 10901 -----------------
0x00007fc87c888425    gsignal + 0x35
0x00007fc87c18c7c0    _ZN7VMError14report_and_dieEv + 0x750
0x00007fc87b9ceecc    _Z15report_vm_errorPKciS0_S0_ + 0x7c
0x00007fc87bd92269 
_ZN8CallInfo10set_handleE12methodHandle6HandleS1_P6Thread.constprop.146 
+ 0x89
0x00007fc87bd92585 
_ZN12LinkResolver19resolve_handle_callER8CallInfo11KlassHandleP6SymbolS4_S2_P6Thread 
+ 0x155
0x00007fc87bd926f6 
_ZN12LinkResolver20resolve_invokehandleER8CallInfo18constantPoolHandleiP6Thread 
+ 0x126
0x00007fc87bd996b4 
_ZN12LinkResolver14resolve_invokeER8CallInfo6Handle18constantPoolHandleiN9Bytecodes4CodeEP6Thread 
+ 0x154
0x00007fc87bbe1d26 
_ZN18InterpreterRuntime20resolve_invokehandleEP10JavaThread + 0x226
0x00007fc86e043475    * Test6990212.main(java.lang.String[]) bci:26 
line:50 Method*:0x00007fc879b937b0 (Interpreted frame)
0x00007fc86e000681    <StubRoutines>
0x00007fc87bbef138 
_ZN9JavaCalls11call_helperEP9JavaValueP12methodHandleP17JavaCallArgumentsP6Thread 
+ 0x1b18
0x00007fc87bc3e99e 
_ZL17jni_invoke_staticP7JNIEnv_P9JavaValueP8_jobject11JNICallTypeP10_jmethodIDP18JNI_ArgumentPusherP6Thread.isra.188.constprop.193 
+ 0x70e
0x00007fc87bc443a4    jni_CallStaticVoidMethod + 0x1b4
0x00007fc87ce1c7e4    JavaMain + 0x844
Locked ownable synchronizers:
     - None



More information about the serviceability-dev mailing list