RFR: 8259008: ArithmeticException was thrown at "Monitor Cache Dump" on HSDB [v2]
Daniel D.Daugherty
dcubed at openjdk.java.net
Fri Jan 22 18:07:48 UTC 2021
On Tue, 19 Jan 2021 08:58:10 GMT, Yasumasa Suenaga <ysuenaga at openjdk.org> wrote:
>> I saw the exception as following when I chose "Monitor Cache Dump" menu on HSDB:
>>
>> Exception in thread "AWT-EventQueue-0" java.lang.ExceptionInInitializerError
>> at jdk.hotspot.agent/sun.jvm.hotspot.ui.MonitorCacheDumpPanel.dumpOn(MonitorCacheDumpPanel.java:92)
>> at jdk.hotspot.agent/sun.jvm.hotspot.ui.MonitorCacheDumpPanel.<init>(MonitorCacheDumpPanel.java:59)
>> at jdk.hotspot.agent/sun.jvm.hotspot.HSDB.showMonitorCacheDumpPanel(HSDB.java:1556)
>> at jdk.hotspot.agent/sun.jvm.hotspot.HSDB$16.actionPerformed(HSDB.java:338)
>> at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1972)
>> at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2313)
>> at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405)
>> at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
>> at java.desktop/javax.swing.AbstractButton.doClick(AbstractButton.java:374)
>> at java.desktop/javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1022)
>> at java.desktop/javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1066)
>> at java.desktop/java.awt.Component.processMouseEvent(Component.java:6617)
>> at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3342)
>> at java.desktop/java.awt.Component.processEvent(Component.java:6382)
>> at java.desktop/java.awt.Container.processEvent(Container.java:2264)
>> at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:4993)
>> at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2322)
>> at java.desktop/java.awt.Component.dispatchEvent(Component.java:4825)
>> at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4934)
>> at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4563)
>> at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4504)
>> at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2308)
>> at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2773)
>> at java.desktop/java.awt.Component.dispatchEvent(Component.java:4825)
>> at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772)
>> at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
>> at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
>> at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
>> at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
>> at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
>> at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
>> at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743)
>> at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
>> at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
>> at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
>> at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
>> at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
>> at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
>> at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
>> at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
>> at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
>> Caused by: java.lang.ArithmeticException: / by zero
>> at jdk.hotspot.agent/sun.jvm.hotspot.runtime.ObjectSynchronizer.initialize(ObjectSynchronizer.java:55)
>> at jdk.hotspot.agent/sun.jvm.hotspot.runtime.ObjectSynchronizer$1.update(ObjectSynchronizer.java:40)
>> at jdk.hotspot.agent/sun.jvm.hotspot.runtime.VM.registerVMInitializedObserver(VM.java:578)
>> at jdk.hotspot.agent/sun.jvm.hotspot.runtime.ObjectSynchronizer.<clinit>(ObjectSynchronizer.java:38)
>> ... 41 more
>>
>> This exception seems to be caused by [JDK-8253064](https://bugs.openjdk.java.net/browse/JDK-8253064). It has changed `ObjectSynchronizer`, but it has not changed SA code.
>
> Yasumasa Suenaga has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains three commits:
>
> - Fix comments
> - Merge
> - 8259008: ArithmeticException was thrown at "Monitor Cache Dump" on HSDB
Generally looks good. I have a few cleanup suggestions.
Also, @fisk needs to chime in on this code review.
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ObjectSynchronizer.java line 60:
> 58: int needLines = ((int)objectMonitorTypeSize / defaultCacheLineSize) + 1;
> 59: objectMonitorTypeSize = needLines * defaultCacheLineSize;
> 60: }
We still align some of the fields in ObjectMonitor on cache lines,
but we no longer allocate ObjectMonitors on cache line boundaries
nor do we wrap ObjectMonitor with the "PaddedEnd<ObjectMonitor>"
construct. So all this cache line stuff as related to the alignment of
the ObjectMonitor or the size of the ObjectMonitor is no longer true.
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ObjectSynchronizer.java line 49:
> 47: try {
> 48: type = db.lookupType("ObjectSynchronizer");
> 49: inUseList = type.getAddressField("_in_use_list").getValue();
@fisk and I somehow missed this use of "g_block_list" when we were putting
together the changes for https://bugs.openjdk.java.net/browse/JDK-8253064.
Sorry about that!
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ObjectSynchronizer.java line 124:
> 122: private static Address inUseList;
> 123: private static int defaultCacheLineSize;
> 124: private static long objectMonitorTypeSize;
I would check the use of these two variables and see if
the code is needed anymore.
test/hotspot/jtreg/serviceability/sa/TestObjectMonitorIterate.java line 78:
> 76: SATestUtils.addPrivilegesIfNeeded(processBuilder);
> 77: OutputAnalyzer SAOutput = ProcessTools.executeProcess(processBuilder);
> 78: SAOutput.shouldHaveExitValue(0);
Is it reasonable to expect at least one ObjectMonitor to be found?
There are a couple of system threads that wait on ObjectMonitors
so if the target VM runs for a little bit of time, there will be at least
two contended ObjectMonitors.
src/hotspot/share/runtime/synchronizer.hpp line 39:
> 37: class ThreadsList;
> 38:
> 39: class MonitorList {
I guess we can't hide MonitorList and MonitorList::Iterator
in synchronizer.cpp as implementation details any more.
src/hotspot/share/runtime/synchronizer.cpp line 217:
> 215: }
> 216:
> 217: MonitorList ObjectSynchronizer::_in_use_list;
I guess we can't hide the _in_use_list as a implementation detail anymore.
-------------
Changes requested by dcubed (Reviewer).
PR: https://git.openjdk.java.net/jdk/pull/1910
More information about the hotspot-runtime-dev
mailing list