GLJPanel Native crash when sharing context of offscreen drawable

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

GLJPanel Native crash when sharing context of offscreen drawable

npryor
Here's my basic problem: I'm trying to share a context between an offscreen drawable (which will be the original drawable) and one or more GLJPanels.  After hundreds of attempts of trial-and-errors and reading through the metadata for JOGL, I found a combination and ordering worked for all dozen of the machines I tested it against.  And then when I got my new computer, lo and behold it gave a fatal native crash when trying to display the GLPanel.  Here's code broken down into the smallest unit I can manage (Kotlin, but should be earily readable for Java users):

fun main( args: Array<String>) {
    UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName())

    val frame = JglpanelDemo()
    frame.pack()
    frame.setSize(100, 100)
    frame.isLocationByPlatform = true
    frame.isVisible = true
    frame.defaultCloseOperation = WindowConstants.EXIT_ON_CLOSE
}

class JglpanelDemo : JFrame() {
    init {
        val profile = GLProfile.getDefault()
        val fact = GLDrawableFactory.getFactory(profile)
        val caps = GLCapabilities(profile)

        val offscreenDrawable = fact.createOffscreenAutoDrawable(fact.defaultDevice,caps,DefaultGLCapabilitiesChooser(),1, 1)
        offscreenDrawable.display()

        val gljPanel = GLJPanel()
        gljPanel.addGLEventListener(object : GLEventListener {
            override fun reshape(drawable: GLAutoDrawable?, x: Int, y: Int, width: Int, height: Int) {}

            override fun display(drawable: GLAutoDrawable) {
                drawable.context.makeCurrent()
                drawable.gl.gL2.glClearBufferfv(GL2.GL_COLOR, 0, FloatBuffer.wrap(floatArrayOf(1f,0f,0f,1f)))
                drawable.context.release()
            }

            override fun init(drawable: GLAutoDrawable) {
                // Disassociate default context and assosciate the context from the GLEngine
                // (so they can share resources)
                val primaryContext = offscreenDrawable.context

                val unusedDefaultContext = drawable.context
                unusedDefaultContext.makeCurrent()
                drawable.setContext(null, true)

                val subContext = drawable.createContext(primaryContext)
                subContext.makeCurrent()
                drawable.setContext(subContext, true)
            }

            override fun dispose(drawable: GLAutoDrawable?) {}
        })

        add(gljPanel)
    }
}

When run on this machine it crashes at the end of GLJPanel's paintComponent with the relatively unhelpful message:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000002827fe80, pid=5556, tid=0x0000000000002b98
#
# JRE version: Java(TM) SE Runtime Environment (8.0_171-b11) (build 1.8.0_171-b11)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.171-b11 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C  0x000000002827fe80
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Documents\Programming\Kotlin\_Spirite\hs_err_pid5556.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

So Question #1 is how to get it to not crash.
Question #2 is: does there exist a tutorial / documentation explaining how to use contexts and shared contexts, when to create, when to makeCurrent, release, etc?  I've done my best to piece together a working understanding from of metadata comments and other people's error questions, but judging by the sheer amount of device-dependent behavior I am encountering I clearly do not understand very well despite attempts to.
Reply | Threaded
Open this post in threaded view
|

Re: GLJPanel Native crash when sharing context of offscreen drawable

npryor
Forgot to include the actual log file in case it is helpful:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000002827fe80, pid=5556, tid=0x0000000000002b98
#
# JRE version: Java(TM) SE Runtime Environment (8.0_171-b11) (build 1.8.0_171-b11)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.171-b11 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C  0x000000002827fe80
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

---------------  T H R E A D  ---------------

Current thread (0x000000001bc3c000):  JavaThread "AWT-EventQueue-0" [_thread_in_native, id=11160, stack(0x0000000027d50000,0x0000000027e50000)]

siginfo: ExceptionCode=0xc0000005, reading address 0x0000000000000000

Registers:
RAX=0x00000000210a1460, RBX=0x000000002b8f0000, RCX=0x0000000000000000, RDX=0x0000000000000004
RSP=0x0000000027e4be80, RBP=0x000000002bb4f040, RSI=0x0000000000000000, RDI=0x0000000000000000
R8 =0x0000000000000000, R9 =0x0000000000000004, R10=0x000000002bb4f040, R11=0x0000000000000000
R12=0x0000000000000000, R13=0x0000000000000000, R14=0x0000000000000005, R15=0x00000000210a1460
RIP=0x000000002827fe80, EFLAGS=0x0000000000010202

Top of Stack: (sp=0x0000000027e4be80)
0x0000000027e4be80:   0000000020fd8d58 0000000000000000
0x0000000027e4be90:   0000000000000004 000000002b8f0000
0x0000000027e4bea0:   000000002bb4f040 00000000687273a9
0x0000000027e4beb0:   000000002b8f0000 000000002bb4f040
0x0000000027e4bec0:   0000000000000004 000000002b8f0000
0x0000000027e4bed0:   0000000027e4bf00 000000002bc51b2c
0x0000000027e4bee0:   0000000000000000 000000002b9477f8
0x0000000027e4bef0:   0000000000000005 000000002bb4f040
0x0000000027e4bf00:   0000000000000004 0000000000000000
0x0000000027e4bf10:   000000002b8f0000 0000000068723c7d
0x0000000027e4bf20:   0000000000000000 0000000000000005
0x0000000027e4bf30:   0000000027c84501 0000000000000000
0x0000000027e4bf40:   0000000000000083 0080000000000000
0x0000000027e4bf50:   0000000000000004 0000000068723edb
0x0000000027e4bf60:   000000002b8f0000 000000002b9477f8
0x0000000027e4bf70:   000000002bb4f040 0000000000000005

Instructions: (pc=0x000000002827fe80)
0x000000002827fe60:   c8 49 8b d1 48 be d0 82 94 2b 00 00 00 00 48 8b
0x000000002827fe70:   36 48 8b b6 08 03 00 00 48 8d 3c 89 48 8d 34 be
0x000000002827fe80:   8b 3e 8b 6e 04 89 38 89 68 04 8b 7e 08 89 78 08
0x000000002827fe90:   48 be d0 82 94 2b 00 00 00 00 48 8b 36 48 8b b6


Register to memory mapping:

RAX=0x00000000210a1460 is an unknown value
RBX=0x000000002b8f0000 is an unknown value
RCX=0x0000000000000000 is an unknown value
RDX=0x0000000000000004 is an unknown value
RSP=0x0000000027e4be80 is pointing into the stack for thread: 0x000000001bc3c000
RBP=0x000000002bb4f040 is an unknown value
RSI=0x0000000000000000 is an unknown value
RDI=0x0000000000000000 is an unknown value
R8 =0x0000000000000000 is an unknown value
R9 =0x0000000000000004 is an unknown value
R10=0x000000002bb4f040 is an unknown value
R11=0x0000000000000000 is an unknown value
R12=0x0000000000000000 is an unknown value
R13=0x0000000000000000 is an unknown value
R14=0x0000000000000005 is an unknown value
R15=0x00000000210a1460 is an unknown value


Stack: [0x0000000027d50000,0x0000000027e50000],  sp=0x0000000027e4be80,  free space=1007k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  0x000000002827fe80

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  jogamp.opengl.gl4.GL4bcImpl.dispatch_glDrawArrays1(IIIJ)V+0
j  jogamp.opengl.gl4.GL4bcImpl.glDrawArrays(III)V+45
j  jogamp.opengl.util.glsl.GLSLTextureRaster.display(Lcom/jogamp/opengl/GL2ES2;)V+30
j  com.jogamp.opengl.awt.GLJPanel$OffscreenBackend.postGL(Ljava/awt/Graphics;Z)V+1861
j  com.jogamp.opengl.awt.GLJPanel$Updater.display(Lcom/jogamp/opengl/GLAutoDrawable;)V+215
j  com.jogamp.opengl.awt.GLJPanel$10.run()V+11
j  jogamp.opengl.GLDrawableHelper.invokeGLImpl(Lcom/jogamp/opengl/GLDrawable;Lcom/jogamp/opengl/GLContext;Ljava/lang/Runnable;Ljava/lang/Runnable;)V+203
j  jogamp.opengl.GLDrawableHelper.invokeGL(Lcom/jogamp/opengl/GLDrawable;Lcom/jogamp/opengl/GLContext;Ljava/lang/Runnable;Ljava/lang/Runnable;)V+72
j  com.jogamp.opengl.awt.GLJPanel$OffscreenBackend.doPaintComponent(Ljava/awt/Graphics;)V+29
j  com.jogamp.opengl.awt.GLJPanel.paintComponent(Ljava/awt/Graphics;)V+224
j  javax.swing.JComponent.paint(Ljava/awt/Graphics;)V+286
j  javax.swing.JComponent.paintChildren(Ljava/awt/Graphics;)V+501
j  javax.swing.JComponent.paint(Ljava/awt/Graphics;)V+318
j  javax.swing.JComponent.paintChildren(Ljava/awt/Graphics;)V+501
j  javax.swing.JComponent.paint(Ljava/awt/Graphics;)V+318
j  javax.swing.JLayeredPane.paint(Ljava/awt/Graphics;)V+73
j  javax.swing.JComponent.paintChildren(Ljava/awt/Graphics;)V+501
j  javax.swing.JComponent.paintToOffscreen(Ljava/awt/Graphics;IIIIII)V+72
j  javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Ljavax/swing/JComponent;Ljava/awt/Image;Ljava/awt/Graphics;IIII)V+163
j  javax.swing.RepaintManager$PaintManager.paint(Ljavax/swing/JComponent;Ljavax/swing/JComponent;Ljava/awt/Graphics;IIII)Z+116
j  javax.swing.RepaintManager.paint(Ljavax/swing/JComponent;Ljavax/swing/JComponent;Ljava/awt/Graphics;IIII)V+51
j  javax.swing.JComponent.paint(Ljava/awt/Graphics;)V+221
j  java.awt.GraphicsCallback$PaintCallback.run(Ljava/awt/Component;Ljava/awt/Graphics;)V+2
j  sun.awt.SunGraphicsCallback.runOneComponent(Ljava/awt/Component;Ljava/awt/Rectangle;Ljava/awt/Graphics;Ljava/awt/Shape;I)V+155
j  sun.awt.SunGraphicsCallback.runComponents([Ljava/awt/Component;Ljava/awt/Graphics;I)V+194
j  java.awt.Container.paint(Ljava/awt/Graphics;)V+58
j  java.awt.Window.paint(Ljava/awt/Graphics;)V+68
j  javax.swing.RepaintManager$4.run()Ljava/lang/Void;+142
j  javax.swing.RepaintManager$4.run()Ljava/lang/Object;+1
v  ~StubRoutines::call_stub
j  java.security.AccessController.doPrivileged(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;)Ljava/lang/Object;+0
j  java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;Ljava/security/AccessControlContext;)Ljava/lang/Object;+18
j  javax.swing.RepaintManager.paintDirtyRegions(Ljava/util/Map;)V+154
j  javax.swing.RepaintManager.paintDirtyRegions()V+46
j  javax.swing.RepaintManager.prePaintDirtyRegions()V+73
j  javax.swing.RepaintManager.access$1200(Ljavax/swing/RepaintManager;)V+1
j  javax.swing.RepaintManager$ProcessingRunnable.run()V+37
j  java.awt.event.InvocationEvent.dispatch()V+47
j  java.awt.EventQueue.dispatchEventImpl(Ljava/awt/AWTEvent;Ljava/lang/Object;)V+21
j  java.awt.EventQueue.access$500(Ljava/awt/EventQueue;Ljava/awt/AWTEvent;Ljava/lang/Object;)V+3
j  java.awt.EventQueue$3.run()Ljava/lang/Void;+32
j  java.awt.EventQueue$3.run()Ljava/lang/Object;+1
v  ~StubRoutines::call_stub
j  java.security.AccessController.doPrivileged(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;)Ljava/lang/Object;+0
j  java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;Ljava/security/AccessControlContext;)Ljava/lang/Object;+18
j  java.awt.EventQueue.dispatchEvent(Ljava/awt/AWTEvent;)V+46
j  java.awt.EventDispatchThread.pumpOneEventForFilters(I)V+140
j  java.awt.EventDispatchThread.pumpEventsForFilter(ILjava/awt/Conditional;Ljava/awt/EventFilter;)V+35
j  java.awt.EventDispatchThread.pumpEventsForHierarchy(ILjava/awt/Conditional;Ljava/awt/Component;)V+11
j  java.awt.EventDispatchThread.pumpEvents(ILjava/awt/Conditional;)V+4
j  java.awt.EventDispatchThread.pumpEvents(Ljava/awt/Conditional;)V+3
j  java.awt.EventDispatchThread.run()V+9
v  ~StubRoutines::call_stub

---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )
  0x0000000003026800 JavaThread "DestroyJavaVM" [_thread_blocked, id=6312, stack(0x0000000002d30000,0x0000000002e30000)]
  0x000000001bba7000 JavaThread "main-SharedResourceRunner" daemon [_thread_blocked, id=7460, stack(0x0000000028050000,0x0000000028150000)]
=>0x000000001bc3c000 JavaThread "AWT-EventQueue-0" [_thread_in_native, id=11160, stack(0x0000000027d50000,0x0000000027e50000)]
  0x000000001b8ee000 JavaThread "AWT-Windows" daemon [_thread_in_native, id=9016, stack(0x000000001c260000,0x000000001c360000)]
  0x000000001b8ed000 JavaThread "AWT-Shutdown" [_thread_blocked, id=9272, stack(0x000000001c160000,0x000000001c260000)]
  0x000000001b8ec800 JavaThread "Java2D Disposer" daemon [_thread_blocked, id=12344, stack(0x000000001c060000,0x000000001c160000)]
  0x0000000019d51800 JavaThread "Service Thread" daemon [_thread_blocked, id=12408, stack(0x000000001b520000,0x000000001b620000)]
  0x0000000019cb6000 JavaThread "C1 CompilerThread3" daemon [_thread_blocked, id=5100, stack(0x000000001b420000,0x000000001b520000)]
  0x0000000019cb5800 JavaThread "C2 CompilerThread2" daemon [_thread_blocked, id=5612, stack(0x000000001b320000,0x000000001b420000)]
  0x0000000019cb4800 JavaThread "C2 CompilerThread1" daemon [_thread_blocked, id=10528, stack(0x000000001b220000,0x000000001b320000)]
  0x0000000019cb2000 JavaThread "C2 CompilerThread0" daemon [_thread_blocked, id=1248, stack(0x000000001b120000,0x000000001b220000)]
  0x0000000019cae800 JavaThread "Monitor Ctrl-Break" daemon [_thread_in_native, id=5564, stack(0x000000001b020000,0x000000001b120000)]
  0x00000000199d5800 JavaThread "Attach Listener" daemon [_thread_blocked, id=7312, stack(0x000000001af20000,0x000000001b020000)]
  0x00000000199d3000 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=15544, stack(0x000000001ae20000,0x000000001af20000)]
  0x0000000018309000 JavaThread "Finalizer" daemon [_thread_blocked, id=9112, stack(0x000000001ac30000,0x000000001ad30000)]
  0x00000000182fe000 JavaThread "Reference Handler" daemon [_thread_blocked, id=11968, stack(0x000000001ab30000,0x000000001ac30000)]

Other Threads:
  0x000000000311d000 VMThread [stack: 0x000000001aa30000,0x000000001ab30000] [id=2668]
  0x000000001b68f000 WatcherThread [stack: 0x000000001be20000,0x000000001bf20000] [id=6064]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap:
 PSYoungGen      total 38400K, used 18038K [0x00000000d5b00000, 0x00000000d8580000, 0x0000000100000000)
  eden space 33280K, 42% used [0x00000000d5b00000,0x00000000d68a9eb0,0x00000000d7b80000)
  from space 5120K, 79% used [0x00000000d7b80000,0x00000000d7f73978,0x00000000d8080000)
  to   space 5120K, 0% used [0x00000000d8080000,0x00000000d8080000,0x00000000d8580000)
 ParOldGen       total 87552K, used 0K [0x0000000081000000, 0x0000000086580000, 0x00000000d5b00000)
  object space 87552K, 0% used [0x0000000081000000,0x0000000081000000,0x0000000086580000)
 Metaspace       used 15408K, capacity 15640K, committed 15872K, reserved 1062912K
  class space    used 1574K, capacity 1670K, committed 1792K, reserved 1048576K

Card table byte_map: [0x00000000124e0000,0x00000000128e0000] byte_map_base: 0x00000000120d8000

Marking Bits: (ParMarkBitMap*) 0x000000006acd08c0
 Begin Bits: [0x0000000013590000, 0x0000000015550000)
 End Bits:   [0x0000000015550000, 0x0000000017510000)

Polling page: 0x00000000009e0000

CodeCache: size=245760Kb used=3198Kb max_used=3198Kb free=242561Kb
 bounds [0x0000000003120000, 0x0000000003450000, 0x0000000012120000]
 total_blobs=1581 nmethods=750 adapters=745
 compilation: enabled

Compilation events (10 events):
Event: 1.940 Thread 0x0000000019cb6000 nmethod 745 0x0000000003439bd0 code [0x0000000003439d80, 0x000000000343a518]
Event: 1.940 Thread 0x0000000019cb6000  746       3       java.lang.ClassLoader::defineClass (43 bytes)
Event: 1.941 Thread 0x0000000019cb6000 nmethod 746 0x000000000343a850 code [0x000000000343aa40, 0x000000000343b608]
Event: 1.941 Thread 0x0000000019cb6000  747   !   3       java.lang.ClassLoader::checkCerts (195 bytes)
Event: 1.942 Thread 0x0000000019cb6000 nmethod 747 0x000000000343bd90 code [0x000000000343c040, 0x000000000343d6b8]
Event: 1.942 Thread 0x0000000019cb6000  748       3       java.net.URLClassLoader::getAndVerifyPackage (109 bytes)
Event: 1.942 Thread 0x0000000019cb6000 nmethod 748 0x000000000343e090 code [0x000000000343e380, 0x000000000343fb08]
Event: 1.942 Thread 0x0000000019cb6000  749       3       java.net.URLStreamHandler::equals (45 bytes)
Event: 1.943 Thread 0x0000000019cb6000 nmethod 749 0x0000000003440590 code [0x0000000003440720, 0x0000000003440c38]
Event: 1.943 Thread 0x0000000019cb6000  750       3       java.net.URLStreamHandler::hostsEqual (75 bytes)

GC Heap History (2 events):
Event: 1.560 GC heap before
{Heap before GC invocations=1 (full 0):
 PSYoungGen      total 38400K, used 33280K [0x00000000d5b00000, 0x00000000d8580000, 0x0000000100000000)
  eden space 33280K, 100% used [0x00000000d5b00000,0x00000000d7b80000,0x00000000d7b80000)
  from space 5120K, 0% used [0x00000000d8080000,0x00000000d8080000,0x00000000d8580000)
  to   space 5120K, 0% used [0x00000000d7b80000,0x00000000d7b80000,0x00000000d8080000)
 ParOldGen       total 87552K, used 0K [0x0000000081000000, 0x0000000086580000, 0x00000000d5b00000)
  object space 87552K, 0% used [0x0000000081000000,0x0000000081000000,0x0000000086580000)
 Metaspace       used 13116K, capacity 13260K, committed 13440K, reserved 1060864K
  class space    used 1297K, capacity 1348K, committed 1408K, reserved 1048576K
Event: 1.570 GC heap after
Heap after GC invocations=1 (full 0):
 PSYoungGen      total 38400K, used 4046K [0x00000000d5b00000, 0x00000000d8580000, 0x0000000100000000)
  eden space 33280K, 0% used [0x00000000d5b00000,0x00000000d5b00000,0x00000000d7b80000)
  from space 5120K, 79% used [0x00000000d7b80000,0x00000000d7f73978,0x00000000d8080000)
  to   space 5120K, 0% used [0x00000000d8080000,0x00000000d8080000,0x00000000d8580000)
 ParOldGen       total 87552K, used 0K [0x0000000081000000, 0x0000000086580000, 0x00000000d5b00000)
  object space 87552K, 0% used [0x0000000081000000,0x0000000081000000,0x0000000086580000)
 Metaspace       used 13116K, capacity 13260K, committed 13440K, reserved 1060864K
  class space    used 1297K, capacity 1348K, committed 1408K, reserved 1048576K
}

Deoptimization events (4 events):
Event: 0.269 Thread 0x0000000003026800 Uncommon trap: reason=null_check action=make_not_entrant pc=0x000000000329dca0 method=java.lang.String.equals(Ljava/lang/Object;)Z @ 8
Event: 0.473 Thread 0x0000000003026800 Uncommon trap: reason=unstable_if action=reinterpret pc=0x00000000032e4550 method=java.lang.String.indexOf([CII[CIII)I @ 3
Event: 1.704 Thread 0x000000001bba7000 Uncommon trap: reason=unstable_if action=reinterpret pc=0x00000000033f8948 method=java.lang.Class.searchFields([Ljava/lang/reflect/Field;Ljava/lang/String;)Ljava/lang/reflect/Field; @ 20
Event: 1.811 Thread 0x0000000003026800 Uncommon trap: reason=unstable_if action=reinterpret pc=0x00000000033f4ff4 method=java.lang.reflect.AccessibleObject.setAccessible0(Ljava/lang/reflect/AccessibleObject;Z)V @ 4

Classes redefined (0 events):
No events

Internal exceptions (10 events):
Event: 0.181 Thread 0x0000000003026800 Exception  (0x00000000d5d79d70) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u171\10807\hotspot\src\share\vm\prims\jvm.cpp, line 1435]
Event: 0.181 Thread 0x0000000003026800 Exception
 (0x00000000d5d79f80) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u171\10807\hotspot\src\share\vm\prims\jvm.cpp, line 1435]
Event: 0.184 Thread 0x0000000003026800 Exception
 (0x00000000d5d81740) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u171\10807\hotspot\src\share\vm\prims\jni.cpp, line 709]
Event: 0.215 Thread 0x0000000003026800 Exception
 (0x00000000d5ffe408) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u171\10807\hotspot\src\share\vm\prims\methodHandles.cpp, line 1167]
Event: 0.216 Thread 0x0000000003026800 Exception
 (0x00000000d600c280) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u171\10807\hotspot\src\share\vm\prims\methodHandles.cpp, line 1167]
Event: 0.269 Thread 0x0000000003026800 Implicit null exception at 0x000000000329dae2 to 0x000000000329dc91
Event: 0.275 Thread 0x0000000003026800 Exception
 (0x00000000d62d1cd0) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u171\10807\hotspot\src\share\vm\prims\jni.cpp, line 709]
Event: 0.709 Thread 0x0000000003026800 Exception
 (0x00000000d67098c8) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u171\10807\hotspot\src\share\vm\prims\jni.cpp, line 709]
Event: 0.744 Thread 0x0000000003026800 Exception
 (0x00000000d68c13a0) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u171\10807\hotspot\src\share\vm\prims\jni.cpp, line 709]
Event: 1.705 Thread 0x0000000003026800 Exception
 (0x00000000d62d5d70) thrown at [C:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u171\10807\hotspot\src\share\vm\runtime\objectMonitor.cpp, line 1684]

Events (10 events):
Event: 1.940 loading class com/jogamp/common/util/IntBitfield
Event: 1.940 loading class com/jogamp/common/util/IntBitfield done
Event: 1.941 loading class com/jogamp/opengl/util/GLPixelBuffer$DefaultGLPixelBufferProvider
Event: 1.941 loading class com/jogamp/opengl/util/GLPixelBuffer$DefaultGLPixelBufferProvider done
Event: 1.941 loading class com/jogamp/opengl/util/GLPixelBuffer$GLPixelAttributes
Event: 1.941 loading class com/jogamp/opengl/util/GLPixelBuffer$GLPixelAttributes done
Event: 1.942 loading class java/nio/HeapIntBuffer
Event: 1.942 loading class java/nio/HeapIntBuffer done
Event: 1.942 loading class jogamp/opengl/GLStateTracker$SavedState
Event: 1.942 loading class jogamp/opengl/GLStateTracker$SavedState done


Dynamic libraries:
0x00007ff6a9630000 - 0x00007ff6a9667000 C:\Program Files\Java\jdk1.8.0_171\bin\java.exe
0x00007ffb97c80000 - 0x00007ffb97e61000 C:\WINDOWS\SYSTEM32\ntdll.dll
0x00007ffb973f0000 - 0x00007ffb974a2000 C:\WINDOWS\System32\KERNEL32.DLL
0x00007ffb94a50000 - 0x00007ffb94cc3000 C:\WINDOWS\System32\KERNELBASE.dll
0x00007ffb953f0000 - 0x00007ffb95491000 C:\WINDOWS\System32\ADVAPI32.dll
0x00007ffb95340000 - 0x00007ffb953de000 C:\WINDOWS\System32\msvcrt.dll
0x00007ffb97b80000 - 0x00007ffb97bdb000 C:\WINDOWS\System32\sechost.dll
0x00007ffb95a30000 - 0x00007ffb95b54000 C:\WINDOWS\System32\RPCRT4.dll
0x00007ffb954a0000 - 0x00007ffb95630000 C:\WINDOWS\System32\USER32.dll
0x00007ffb94050000 - 0x00007ffb94070000 C:\WINDOWS\System32\win32u.dll
0x00007ffb95140000 - 0x00007ffb95168000 C:\WINDOWS\System32\GDI32.dll
0x00007ffb94f70000 - 0x00007ffb95102000 C:\WINDOWS\System32\gdi32full.dll
0x00007ffb94cd0000 - 0x00007ffb94d6f000 C:\WINDOWS\System32\msvcp_win.dll
0x00007ffb94dc0000 - 0x00007ffb94eba000 C:\WINDOWS\System32\ucrtbase.dll
0x00007ffb80c70000 - 0x00007ffb80ed9000 C:\WINDOWS\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.17134.165_none_fb429645306569ac\COMCTL32.dll
0x00007ffb95650000 - 0x00007ffb95973000 C:\WINDOWS\System32\combase.dll
0x00007ffb94070000 - 0x00007ffb940ea000 C:\WINDOWS\System32\bcryptPrimitives.dll
0x00007ffb95110000 - 0x00007ffb9513d000 C:\WINDOWS\System32\IMM32.DLL
0x000000006ad50000 - 0x000000006ae22000 C:\Program Files\Java\jdk1.8.0_171\jre\bin\msvcr100.dll
0x000000006a4b0000 - 0x000000006ad50000 C:\Program Files\Java\jdk1.8.0_171\jre\bin\server\jvm.dll
0x00007ffb953e0000 - 0x00007ffb953e8000 C:\WINDOWS\System32\PSAPI.DLL
0x00007ffb6c090000 - 0x00007ffb6c099000 C:\WINDOWS\SYSTEM32\WSOCK32.dll
0x00007ffb8a3e0000 - 0x00007ffb8a403000 C:\WINDOWS\SYSTEM32\WINMM.dll
0x00007ffb8f920000 - 0x00007ffb8f92a000 C:\WINDOWS\SYSTEM32\VERSION.dll
0x00007ffb97be0000 - 0x00007ffb97c4c000 C:\WINDOWS\System32\WS2_32.dll
0x00007ffb8a390000 - 0x00007ffb8a3ba000 C:\WINDOWS\SYSTEM32\winmmbase.dll
0x00007ffb94d70000 - 0x00007ffb94db9000 C:\WINDOWS\System32\cfgmgr32.dll
0x000000006a4a0000 - 0x000000006a4af000 C:\Program Files\Java\jdk1.8.0_171\jre\bin\verify.dll
0x000000006a470000 - 0x000000006a499000 C:\Program Files\Java\jdk1.8.0_171\jre\bin\java.dll
0x000000006a3d0000 - 0x000000006a3f3000 C:\Program Files\Java\jdk1.8.0_171\jre\bin\instrument.dll
0x000000006a450000 - 0x000000006a466000 C:\Program Files\Java\jdk1.8.0_171\jre\bin\zip.dll
0x00007ffb95ed0000 - 0x00007ffb97310000 C:\WINDOWS\System32\SHELL32.dll
0x00007ffb95980000 - 0x00007ffb95a29000 C:\WINDOWS\System32\shcore.dll
0x00007ffb940f0000 - 0x00007ffb947fd000 C:\WINDOWS\System32\windows.storage.dll
0x00007ffb95e70000 - 0x00007ffb95ec1000 C:\WINDOWS\System32\shlwapi.dll
0x00007ffb93fc0000 - 0x00007ffb93fd1000 C:\WINDOWS\System32\kernel.appcore.dll
0x00007ffb93fe0000 - 0x00007ffb93fff000 C:\WINDOWS\System32\profapi.dll
0x00007ffb94000000 - 0x00007ffb9404c000 C:\WINDOWS\System32\powrprof.dll
0x00007ffb93f90000 - 0x00007ffb93f9a000 C:\WINDOWS\System32\FLTLIB.DLL
0x00007ffb88cf0000 - 0x00007ffb88d0a000 C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.3.3\bin\breakgen64.dll
0x000000006a430000 - 0x000000006a44a000 C:\Program Files\Java\jdk1.8.0_171\jre\bin\net.dll
0x00007ffb93810000 - 0x00007ffb93876000 C:\WINDOWS\system32\mswsock.dll
0x000000006a230000 - 0x000000006a3c8000 C:\Program Files\Java\jdk1.8.0_171\jre\bin\awt.dll
0x00007ffb97320000 - 0x00007ffb973e2000 C:\WINDOWS\System32\OLEAUT32.dll
0x00007ffb915f0000 - 0x00007ffb9167b000 C:\WINDOWS\SYSTEM32\apphelp.dll
0x00007ffb92440000 - 0x00007ffb924d8000 C:\WINDOWS\system32\uxtheme.dll
0x00007ffb95cf0000 - 0x00007ffb95e65000 C:\WINDOWS\System32\MSCTF.dll
0x00007ffb92720000 - 0x00007ffb92749000 C:\WINDOWS\system32\dwmapi.dll
0x00007ffb95170000 - 0x00007ffb952c1000 C:\WINDOWS\System32\ole32.dll
0x00007ffb65300000 - 0x00007ffb65420000 C:\WINDOWS\system32\opengl32.dll
0x00007ffb88150000 - 0x00007ffb8817c000 C:\WINDOWS\SYSTEM32\GLU32.dll
0x00007ffb8de30000 - 0x00007ffb8dfc7000 C:\WINDOWS\system32\d3d9.dll
0x00007ffb867a0000 - 0x00007ffb8688b000 C:\WINDOWS\System32\DriverStore\FileRepository\nv_dispi.inf_amd64_485c1c3102021986\nvldumdx.dll
0x00007ffb94800000 - 0x00007ffb949e2000 C:\WINDOWS\System32\crypt32.dll
0x00007ffb93fa0000 - 0x00007ffb93fb2000 C:\WINDOWS\System32\MSASN1.dll
0x00007ffb949f0000 - 0x00007ffb94a47000 C:\WINDOWS\System32\WINTRUST.DLL
0x00007ffb95630000 - 0x00007ffb9564d000 C:\WINDOWS\System32\imagehlp.dll
0x00007ffb939c0000 - 0x00007ffb939d7000 C:\WINDOWS\SYSTEM32\CRYPTSP.dll
0x00007ffb933f0000 - 0x00007ffb93423000 C:\WINDOWS\system32\rsaenh.dll
0x00007ffb93af0000 - 0x00007ffb93b15000 C:\WINDOWS\SYSTEM32\bcrypt.dll
0x00007ffb939e0000 - 0x00007ffb939eb000 C:\WINDOWS\SYSTEM32\CRYPTBASE.dll
0x00007ffb58fc0000 - 0x00007ffb5a1f8000 C:\WINDOWS\System32\DriverStore\FileRepository\nv_dispi.inf_amd64_485c1c3102021986\nvd3dumx.dll
0x00007ffb83730000 - 0x00007ffb837f3000 C:\Program Files (x86)\NVIDIA Corporation\3D Vision\nvSCPAPI64.dll
0x00007ffb976b0000 - 0x00007ffb97afb000 C:\WINDOWS\System32\SETUPAPI.dll
0x00007ffb92cd0000 - 0x00007ffb92cf2000 C:\WINDOWS\SYSTEM32\gpapi.dll
0x00007ffb8ecd0000 - 0x00007ffb8ecfe000 C:\WINDOWS\SYSTEM32\cryptnet.dll
0x00007ffb93ec0000 - 0x00007ffb93ee8000 C:\WINDOWS\SYSTEM32\USERENV.dll
0x00007ffb93590000 - 0x00007ffb935c8000 C:\WINDOWS\SYSTEM32\IPHLPAPI.DLL
0x00007ffb952d0000 - 0x00007ffb952d8000 C:\WINDOWS\System32\NSI.dll
0x00007ffb8f6c0000 - 0x00007ffb8f6d6000 C:\WINDOWS\SYSTEM32\dhcpcsvc6.DLL
0x00007ffb8f6a0000 - 0x00007ffb8f6ba000 C:\WINDOWS\SYSTEM32\dhcpcsvc.DLL
0x000000006a410000 - 0x000000006a421000 C:\Program Files\Java\jdk1.8.0_171\jre\bin\nio.dll
0x00000000637c0000 - 0x00000000637cd000 C:\Users\rorya\AppData\Local\Temp\jogamp_0000\file_cache\jln3420184237681554341\jln5181092968547821391\gluegen-rt.dll
0x000000006a220000 - 0x000000006a227000 C:\Program Files\Java\jdk1.8.0_171\jre\bin\jawt.dll
0x000000001c380000 - 0x000000001c38d000 C:\Users\rorya\AppData\Local\Temp\jogamp_0000\file_cache\jln3420184237681554341\jln5181092968547821391\nativewindow_awt.dll
0x000000006c100000 - 0x000000006c10f000 C:\Users\rorya\AppData\Local\Temp\jogamp_0000\file_cache\jln3420184237681554341\jln5181092968547821391\nativewindow_win32.dll
0x0000000064500000 - 0x00000000645ae000 C:\Users\rorya\AppData\Local\Temp\jogamp_0000\file_cache\jln3420184237681554341\jln5181092968547821391\jogl_desktop.dll
0x0000000064340000 - 0x00000000643a0000 C:\Users\rorya\AppData\Local\Temp\jogamp_0000\file_cache\jln3420184237681554341\jln5181092968547821391\jogl_mobile.dll
0x0000000067b90000 - 0x000000006a215000 C:\WINDOWS\System32\DriverStore\FileRepository\nv_dispi.inf_amd64_485c1c3102021986\nvoglv64.dll
0x00007ffb91d60000 - 0x00007ffb91d73000 C:\WINDOWS\SYSTEM32\WTSAPI32.dll
0x00007ffb93da0000 - 0x00007ffb93dc7000 C:\WINDOWS\SYSTEM32\DEVOBJ.dll
0x00007ffb93190000 - 0x00007ffb931c1000 C:\WINDOWS\SYSTEM32\ntmarta.dll
0x00007ffb93130000 - 0x00007ffb93186000 C:\WINDOWS\SYSTEM32\WINSTA.dll
0x0000000067b40000 - 0x0000000067b87000 C:\Program Files\Java\jdk1.8.0_171\jre\bin\fontmanager.dll
0x00007ffb85d50000 - 0x00007ffb85de8000 C:\WINDOWS\System32\TextInputFramework.dll
0x00007ffb91240000 - 0x00007ffb9131a000 C:\WINDOWS\System32\CoreMessaging.dll
0x00007ffb85df0000 - 0x00007ffb8610e000 C:\WINDOWS\System32\CoreUIComponents.dll
0x00007ffb8f060000 - 0x00007ffb8f1ad000 C:\WINDOWS\SYSTEM32\wintypes.dll
0x00007ffb8edf0000 - 0x00007ffb8efb9000 C:\WINDOWS\SYSTEM32\dbghelp.dll

VM Arguments:
jvm_args: -javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.3.3\lib\idea_rt.jar=58364:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.3.3\bin -Dfile.encoding=UTF-8
java_command: demonstration.gl.JglpanelDemoKt
java_class_path (initial): C:\Program Files\Java\jdk1.8.0_171\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_171\jre\lib\rt.jar;C:\Documents\Programming\Kotlin\_Spirite\out\test\classes;C:\Documents\Programming\Kotlin\_Spirite\out\production\classes;C:\Documents\Programming\Kotlin\_Spirite\out\production\resources;C:\Users\rorya\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib-jdk8\1.2.50\baf551dec8b4dc94c9dd59561400f16b3b5835a6\kotlin-stdlib-jdk8-1.2.50.jar;C:\Users\rorya\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlinx\kotlinx-coroutines-core\0.22.5\a654b6962cbdf394cd88e6fc173314c92dd50edb\kotlinx-coroutines-core-0.22.5.jar;C:\Users\rorya\.gradle\caches\modules-2\files-2.1\org.jogamp.gluegen\gluegen-rt\2.3.1\b28a5ed162a28ab18f3018c6e254
Launcher Type: SUN_STANDARD

Environment Variables:
PATH=C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\ProgramData\chocolatey\bin;;C:\WINDOWS\System32\OpenSSH\;C:\Users\rorya\AppData\Local\Microsoft\WindowsApps;
USERNAME=rorya
OS=Windows_NT
PROCESSOR_IDENTIFIER=AMD64 Family 23 Model 1 Stepping 1, AuthenticAMD



---------------  S Y S T E M  ---------------

OS: Windows 10.0 , 64 bit Build 17134 (10.0.17134.1)

CPU:total 12 (initial active 12) (12 cores per cpu, 1 threads per core) family 23 model 1 stepping 1, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, avx, avx2, aes, clmul, mmxext, 3dnowpref, lzcnt, sse4a, tsc, tscinvbit, tscinv, bmi1

Memory: 4k page, physical 8320696k(1655892k free), swap 19330744k(7051036k free)

vm_info: Java HotSpot(TM) 64-Bit Server VM (25.171-b11) for windows-amd64 JRE (1.8.0_171-b11), built on Mar 28 2018 16:06:12 by "java_re" with MS VC++ 10.0 (VS2010)

time: Wed Jul 11 21:50:50 2018
elapsed time: 1 seconds (0d 0h 0m 1s)

Reply | Threaded
Open this post in threaded view
|

Re: GLJPanel Native crash when sharing context of offscreen drawable

gouessej
Administrator
In reply to this post by npryor
Hey

Your source code is understandable but please provide a SSCCE written in Java. You can look at the source code of several engines based on JOGL in order to see how to use FBOs. Please don't pass an indirect NIO buffer to glClearBufferfv, create a direct NIO buffers with Buffers.newDirectFloatBuffer(), fill it and rewind it.

Are you sure that you don't do anything else not mentioned yet? EXCEPTION_ACCESS_VIOLATION can occur when OpenGL tries to read beyond the limit of a NIO buffer.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: GLJPanel Native crash when sharing context of offscreen drawable

npryor
Fair enough on both counts.

import com.jogamp.common.nio.Buffers;
import com.jogamp.opengl.*;
import com.jogamp.opengl.awt.GLJPanel;

import javax.swing.*;
import java.nio.FloatBuffer;

public class GLCrashTest {
    public static void main(String args[]) {
        try {
            UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());

            JFrame frame = new JglpanelDemo();
            frame.pack();
            frame.setSize(100, 100);
            frame.isLocationByPlatform();
            frame.setVisible(true);
            frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    static class JglpanelDemo extends  JFrame {
        JglpanelDemo() {
            GLProfile profile = GLProfile.getDefault();
            GLDrawableFactory factory = GLDrawableFactory.getFactory(profile);
            GLCapabilities caps = new GLCapabilities(profile);
            caps.setHardwareAccelerated(true);
            caps.setDoubleBuffered(false);
            caps.setAlphaBits(8);
            caps.setRedBits(8);
            caps.setBlueBits(8);
            caps.setGreenBits(8);
            caps.setOnscreen(false);

            GLOffscreenAutoDrawable offscreenDrawable = factory.createOffscreenAutoDrawable(factory.getDefaultDevice(), caps, new DefaultGLCapabilitiesChooser(), 1, 1);
            offscreenDrawable.display();

            GLJPanel glPanel = new GLJPanel();
            glPanel.addGLEventListener(new GLEventListener() {
                @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {}
                @Override public void dispose(GLAutoDrawable drawable) {}

                @Override
                public void display(GLAutoDrawable drawable) {
                    drawable.getContext().makeCurrent();
                    float array[] = {1f, 0f, 0f, 1f};
                    FloatBuffer buf = Buffers.newDirectFloatBuffer(array);
                    buf.rewind();
                    drawable.getGL().getGL2().glClearBufferfv(GL2.GL_COLOR, 0, buf);
                    drawable.getContext().release();
                }

                @Override
                public void init(GLAutoDrawable drawable) {
                    GLContext primaryContext = offscreenDrawable.getContext();

                    GLContext unusedDefaultContext = drawable.getContext();
                    unusedDefaultContext.makeCurrent();
                    drawable.setContext(null, true);


                    GLContext subContext = drawable.createContext(primaryContext);
                    subContext.makeCurrent();
                    drawable.setContext(subContext, true);
                }
            });

            add(glPanel);
        }
    }
}

I also explicitly set the Capabilities this time.

As for glClearBufferfv, this was only added to demonstrate (mostly for me) that the window was drawing; the crash happens with or without this line and, in fact, without anything in display()

This is the only code in the project I'm running.

And I don't think the problem is my understanding FBO's from within my own scope, the problem is I don't have a solid understanding on how JOGL's Contexts wraps and utilizes GL functionality as I have frequently encountered crashes like these and errors along the lines of "Failed to release context after 512 attempts" when I try to make a JOGL context current, release it, or draw on it at the wrong time.  And I have even less grasp of what constitutes the "wrong time" and it seems to be different on every machine I run.
Reply | Threaded
Open this post in threaded view
|

Re: GLJPanel Native crash when sharing context of offscreen drawable

gouessej
Administrator
I see no obvious mistake in your code except that you should create the direct NIO buffer only once.

Please look at our unit tests and tell us whether they crash on your machine too. Your example is quite simple, does it crash on several machines?
Julien Gouesse | Personal blog | Website