Uploaded image for project: 'Kieler Pragmatics'
  1. Kieler Pragmatics
  2. KIPRA-1915

KLighD's PlacementUtil.estimateTextSize provokes JVM crash

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2017/11
    • Fix Version/s: None
    • Labels:
      None

      Description

      Several crash logs (at least under Windows, but most likely also under Mac) indicate that the estimateTextSize method from KLighD's PlacementUtil class provokes a JVM crash. Two excerpts are included (getBoundReferece also calls extimateTextSize).
      After short investigation we believe that the issue is linked to the SWT GC class where native API calls in drawText can indeed crash the JVM when called with invalid contexts (under windows). We will also forward these insights to the existing SWT bug report.
      However, PlacementUtil only uses one static GC for all size estimations. If the GC becomes corrupted, the SWT GC calls will fail (under windows).
      We believe that the corruption occurs when multiple size estimations happen concurrently (e.g. due to recently added label manager requests). drawText doesn't seem to be thread-safe (under windows) as native getHDC calls should be paired with releaseHDC calls.
      synchronize would be a simple OS-independent solution. Alternatively, a refactoring of the static GC pattern in PlacementUitl or OS-dependent code to detect the corruption are also conceivable.

      Two excerpts of the crash logs:

      Stack: [0x0000000036a90000,0x0000000036b90000], sp=0x0000000036b8ddb0, free space=1015k
      Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
      C [KERNELBASE.dll+0x14008]
      C [gdiplus.dll+0x7fb54]
      C [swt-gdip-win32-4758.dll+0x682d]
      C 0x0000000005f7aa92

      Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
      J 9868 org.eclipse.swt.internal.gdip.Gdip.Graphics_MeasureDriverString(JJIJ[FIJLorg/eclipse/swt/internal/gdip/RectF;)I (0 bytes) @ 0x0000000005f7aa14 [0x0000000005f7a980+0x94]
      J 12706 C2 org.eclipse.swt.graphics.GC.drawText(J[CIIIIIILorg/eclipse/swt/internal/win32/TEXTMETRIC;Z)Lorg/eclipse/swt/internal/gdip/RectF; (1036 bytes) @ 0x00000000066ac68c [0x00000000066abfc0+0x6cc]
      J 13438 C2 org.eclipse.swt.graphics.GC.drawText(JLjava/lang/String;IIILorg/eclipse/swt/graphics/Point;)V (660 bytes) @ 0x0000000006f71270 [0x0000000006f706e0+0xb90]
      J 9886 C1 org.eclipse.swt.graphics.GC.textExtentInPixels(Ljava/lang/String;I)Lorg/eclipse/swt/graphics/Point; (222 bytes) @ 0x000000000645c224 [0x000000000645b200+0x1024]
      J 11474 C1 de.cau.cs.kieler.klighd.microlayout.PlacementUtil.estimateTextSize(Lorg/eclipse/swt/graphics/FontData;Ljava/lang/String;)Lde/cau/cs/kieler/klighd/microlayout/Bounds; (217 bytes) @ 0x00000000068fa7ac [0x00000000068f8e60+0x194c]
      J 12904 C1 de.cau.cs.kieler.klighd.microlayout.PlacementUtil.estimateTextSize(Lde/cau/cs/kieler/klighd/krendering/KText;Ljava/lang/String;)Lde/cau/cs/kieler/klighd/microlayout/Bounds; (120 bytes) @ 0x0000000006d58674 [0x0000000006d56840+0x1e34]
      j de.cau.cs.kieler.klighd.labels.management.AbstractKlighdLabelManager.calculateFinalLabelSize(Lorg/eclipse/elk/graph/ElkLabel;Ljava/lang/String;)Lorg/eclipse/elk/core/math/KVector;+45
      j de.cau.cs.kieler.klighd.labels.management.AbstractKlighdLabelManager.manageLabelSize(Ljava/lang/Object;D)Lorg/eclipse/elk/core/math/KVector;+76
      J 13905 C1 org.eclipse.elk.alg.layered.intermediate.LabelManagementProcessor.doManageLabels(Lorg/eclipse/elk/core/labels/ILabelManager;Ljava/lang/Iterable;DDZ)Lorg/eclipse/elk/core/math/KVector; (263 bytes) @ 0x000000000704b1d4 [0x000000000704a8e0+0x8f4]
      j org.eclipse.elk.alg.layered.intermediate.LabelManagementProcessor.manageCenterLabels(Lorg/eclipse/elk/alg/layered/graph/LGraph;Lorg/eclipse/elk/core/labels/ILabelManager;DD)V+142
      j org.eclipse.elk.alg.layered.intermediate.LabelManagementProcessor.process(Lorg/eclipse/elk/alg/layered/graph/LGraph;Lorg/eclipse/elk/core/util/IElkProgressMonitor;)V+69
      j org.eclipse.elk.alg.layered.intermediate.LabelManagementProcessor.process(Ljava/lang/Object;Lorg/eclipse/elk/core/util/IElkProgressMonitor;)V+6
      j org.eclipse.elk.alg.layered.ElkLayered.layout(Lorg/eclipse/elk/alg/layered/graph/LGraph;Lorg/eclipse/elk/core/util/IElkProgressMonitor;)V+351
      j org.eclipse.elk.alg.layered.ElkLayered.doLayout(Lorg/eclipse/elk/alg/layered/graph/LGraph;Lorg/eclipse/elk/core/util/IElkProgressMonitor;)V+67
      j org.eclipse.elk.alg.layered.LayeredLayoutProvider.layout(Lorg/eclipse/elk/graph/ElkNode;Lorg/eclipse/elk/core/util/IElkProgressMonitor;)V+52
      j org.eclipse.elk.core.RecursiveGraphLayoutEngine.layoutRecursively(Lorg/eclipse/elk/graph/ElkNode;Lorg/eclipse/elk/core/util/IElkProgressMonitor;)Ljava/util/List;+503
      j org.eclipse.elk.core.RecursiveGraphLayoutEngine.layoutRecursively(Lorg/eclipse/elk/graph/ElkNode;Lorg/eclipse/elk/core/util/IElkProgressMonitor;)Ljava/util/List;+386
      j org.eclipse.elk.core.RecursiveGraphLayoutEngine.layoutRecursively(Lorg/eclipse/elk/graph/ElkNode;Lorg/eclipse/elk/core/util/IElkProgressMonitor;)Ljava/util/List;+386
      j org.eclipse.elk.core.RecursiveGraphLayoutEngine.layout(Lorg/eclipse/elk/graph/ElkNode;Lorg/eclipse/elk/core/util/IElkProgressMonitor;)V+21
      j org.eclipse.elk.core.service.DiagramLayoutEngine.layout(Lorg/eclipse/elk/core/service/LayoutMapping;Lorg/eclipse/elk/core/util/IElkProgressMonitor;[Lorg/eclipse/elk/core/util/IGraphElementVisitor;)Lorg/eclipse/core/runtime/IStatus;+77
      j org.eclipse.elk.core.service.DiagramLayoutEngine.layout(Lorg/eclipse/elk/core/service/LayoutMapping;Lorg/eclipse/elk/core/util/IElkProgressMonitor;Lorg/eclipse/elk/core/service/DiagramLayoutEngine$Parameters;)Lorg/eclipse/core/runtime/IStatus;+430
      j org.eclipse.elk.core.service.DiagramLayoutEngine$1.execute(Lorg/eclipse/elk/core/util/IElkProgressMonitor;)Lorg/eclipse/core/runtime/IStatus;+57
      j org.eclipse.elk.core.service.util.MonitoredOperation$1.run()V+15
      j java.util.concurrent.ThreadPoolExecutor.runWorker(Ljava/util/concurrent/ThreadPoolExecutor$Worker;)V+95
      j java.util.concurrent.ThreadPoolExecutor$Worker.run()V+5
      j java.lang.Thread.run()V+11
      v ~StubRoutines::call_stub

      Stack: [0x0000000004d00000,0x0000000004e00000], sp=0x0000000004dfd3a0, free space=1012k
      Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
      C [KERNELBASE.dll+0x14008]
      C [gdiplus.dll+0x7fb54]
      C [swt-gdip-win32-4758.dll+0x682d]
      C 0x0000000006ae62d2

      Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
      J 10087 org.eclipse.swt.internal.gdip.Gdip.Graphics_MeasureDriverString(JJIJ[FIJLorg/eclipse/swt/internal/gdip/RectF;)I (0 bytes) @ 0x0000000006ae6254 [0x0000000006ae61c0+0x94]
      J 11642 C2 org.eclipse.swt.graphics.GC.drawText(J[CIIIIIILorg/eclipse/swt/internal/win32/TEXTMETRIC;Z)Lorg/eclipse/swt/internal/gdip/RectF; (1036 bytes) @ 0x00000000066d5b30 [0x00000000066d5480+0x6b0]
      J 11641 C2 org.eclipse.swt.graphics.GC.drawText(JLjava/lang/String;IIILorg/eclipse/swt/graphics/Point;)V (660 bytes) @ 0x00000000066d9cf0 [0x00000000066d9160+0xb90]
      J 13746 C2 de.cau.cs.kieler.klighd.piccolo.internal.nodes.KlighdStyledText.getBoundsReference()Ledu/umd/cs/piccolo/util/PBounds; (38 bytes) @ 0x00000000075cb254 [0x00000000075cab00+0x754]
      J 12201 C1 de.cau.cs.kieler.klighd.piccolo.internal.controller.KLabelRenderingController.handleLabelRendering(Lde/cau/cs/kieler/klighd/krendering/KRendering;Lde/cau/cs/kieler/klighd/piccolo/internal/nodes/KLabelNode;)Lde/cau/cs/kieler/klighd/piccolo/internal/controller/PNodeController; (236 bytes) @ 0x00000000071b299c [0x00000000071b0960+0x203c]
      J 12200 C1 de.cau.cs.kieler.klighd.piccolo.internal.controller.KLabelRenderingController.internalUpdateRendering()Lde/cau/cs/kieler/klighd/piccolo/internal/controller/PNodeController; (39 bytes) @ 0x00000000071ae83c [0x00000000071ae540+0x2fc]
      J 11598 C1 de.cau.cs.kieler.klighd.piccolo.internal.controller.AbstractKGERenderingController.updateRendering()V (98 bytes) @ 0x00000000063c4cdc [0x00000000063c4420+0x8bc]
      j de.cau.cs.kieler.klighd.piccolo.internal.controller.DiagramController$1$1.run()V+123
      J 11277 C1 org.eclipse.swt.widgets.RunnableLock.run(Lorg/eclipse/swt/widgets/Display;)V (50 bytes) @ 0x0000000006e835ec [0x0000000006e834a0+0x14c]
      J 9938 C1 org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Z)Z (188 bytes) @ 0x0000000006a7bc3c [0x0000000006a7b9a0+0x29c]
      J 11569 C1 org.eclipse.swt.widgets.Display.readAndDispatch()Z (101 bytes) @ 0x00000000051697a4 [0x00000000051690a0+0x704]
      j org.eclipse.elk.core.service.util.MonitoredOperation.runUnmonitored(Lorg/eclipse/swt/widgets/Display;Z)V+54
      j org.eclipse.elk.core.service.util.MonitoredOperation.runUnmonitored()V+40
      j org.eclipse.elk.core.service.DiagramLayoutEngine.layout(Lorg/eclipse/ui/IWorkbenchPart;Ljava/lang/Object;Lorg/eclipse/elk/core/util/IElkCancelIndicator;Lorg/eclipse/elk/core/service/DiagramLayoutEngine$Parameters;)Lorg/eclipse/elk/core/service/LayoutMapping;+148
      j org.eclipse.elk.core.service.DiagramLayoutEngine.invokeLayout(Lorg/eclipse/ui/IWorkbenchPart;Ljava/lang/Object;Lorg/eclipse/elk/core/util/IElkCancelIndicator;Lorg/eclipse/elk/core/service/DiagramLayoutEngine$Parameters;)Lorg/eclipse/elk/core/service/LayoutMapping;+55
      j de.cau.cs.kieler.klighd.LightDiagramServices.layoutDiagram(Lde/cau/cs/kieler/klighd/LightDiagramLayoutConfig;)V+505
      j de.cau.cs.kieler.klighd.LightDiagramLayoutConfig.performLayout()V+1
      j de.cau.cs.kieler.klighd.LightDiagramServices.updateDiagram(Lde/cau/cs/kieler/klighd/LightDiagramLayoutConfig;)Z+133
      j de.cau.cs.kieler.klighd.LightDiagramLayoutConfig.performUpdate()Z+1
      j de.cau.cs.kieler.klighd.ui.view.DiagramView.doUpdateDiagram(Ljava/lang/Object;Lde/cau/cs/kieler/klighd/util/KlighdSynthesisProperties;Lde/cau/cs/kieler/klighd/ui/view/controller/AbstractViewUpdateController;Lorg/eclipse/ui/IEditorPart;ZZ)V+284
      j de.cau.cs.kieler.klighd.ui.view.DiagramView.access$5(Lde/cau/cs/kieler/klighd/ui/view/DiagramView;Ljava/lang/Object;Lde/cau/cs/kieler/klighd/util/KlighdSynthesisProperties;Lde/cau/cs/kieler/klighd/ui/view/controller/AbstractViewUpdateController;Lorg/eclipse/ui/IEditorPart;ZZ)V+10
      j de.cau.cs.kieler.klighd.ui.view.DiagramView$10.runInUIThread(Lorg/eclipse/core/runtime/IProgressMonitor;)Lorg/eclipse/core/runtime/IStatus;+31
      j org.eclipse.ui.progress.UIJob.lambda$0(Lorg/eclipse/core/runtime/IProgressMonitor;)V+38
      j org.eclipse.ui.progress.UIJob$$Lambda$322.run()V+8
      J 11277 C1 org.eclipse.swt.widgets.RunnableLock.run(Lorg/eclipse/swt/widgets/Display;)V (50 bytes) @ 0x0000000006e835ec [0x0000000006e834a0+0x14c]
      J 9938 C1 org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Z)Z (188 bytes) @ 0x0000000006a7bc3c [0x0000000006a7b9a0+0x29c]
      J 11569 C1 org.eclipse.swt.widgets.Display.readAndDispatch()Z (101 bytes) @ 0x00000000051697a4 [0x00000000051690a0+0x704]
      j org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run()V+564
      j org.eclipse.core.databinding.observable.Realm.runWithDefault(Lorg/eclipse/core/databinding/observable/Realm;Ljava/lang/Runnable;)V+12
      j org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(Lorg/eclipse/e4/ui/model/application/MApplicationElement;Lorg/eclipse/e4/core/contexts/IEclipseContext;)Ljava/lang/Object;+57
      j org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(Lorg/eclipse/e4/ui/model/application/MApplicationElement;)V+20
      j org.eclipse.ui.internal.Workbench.lambda$3(Lorg/eclipse/swt/widgets/Display;Lorg/eclipse/ui/application/WorkbenchAdvisor;[I)V+451
      j org.eclipse.ui.internal.Workbench$$Lambda$14.run()V+12
      j org.eclipse.core.databinding.observable.Realm.runWithDefault(Lorg/eclipse/core/databinding/observable/Realm;Ljava/lang/Runnable;)V+12
      j org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Lorg/eclipse/swt/widgets/Display;Lorg/eclipse/ui/application/WorkbenchAdvisor;)I+16
      j org.eclipse.ui.PlatformUI.createAndRunWorkbench(Lorg/eclipse/swt/widgets/Display;Lorg/eclipse/ui/application/WorkbenchAdvisor;)I+2
      j org.eclipse.ui.internal.ide.application.IDEApplication.start(Lorg/eclipse/equinox/app/IApplicationContext;)Ljava/lang/Object;+113
      j org.eclipse.equinox.internal.app.EclipseAppHandle.run(Ljava/lang/Object;)Ljava/lang/Object;+135
      j org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(Ljava/lang/Object;)Ljava/lang/Object;+85
      j org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(Ljava/lang/Object;)Ljava/lang/Object;+82
      j org.eclipse.core.runtime.adaptor.EclipseStarter.run(Ljava/lang/Object;)Ljava/lang/Object;+105
      j org.eclipse.core.runtime.adaptor.EclipseStarter.run([Ljava/lang/String;Ljava/lang/Runnable;)Ljava/lang/Object;+132
      v ~StubRoutines::call_stub
      j sun.reflect.NativeMethodAccessorImpl.invoke0(Ljava/lang/reflect/Method;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+0
      j sun.reflect.NativeMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+100
      j sun.reflect.DelegatingMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+6
      j java.lang.reflect.Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+56
      j org.eclipse.equinox.launcher.Main.invokeFramework([Ljava/lang/String;[Ljava/net/URL;)V+205
      j org.eclipse.equinox.launcher.Main.basicRun([Ljava/lang/String;)V+160
      j org.eclipse.equinox.launcher.Main.run([Ljava/lang/String;)I+4
      j org.eclipse.equinox.launcher.Main.main([Ljava/lang/String;)V+10
      v ~StubRoutines::call_stub

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              cds Christoph Daniel Schulze
              Reporter:
              ssm Steven Smyth
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: