Posted by
Xerxes Rånby on
Mar 19, 2013; 10:44am
URL: https://forum.jogamp.org/Shader-crashes-JVM-tp4028702p4028707.html
2013-03-19 01:23, cubus [via jogamp] skrev:
>
>
> this fragment shader crashes the jvm... when running the shader on GLSL Sandbox, everything works.
>
> if either LINE C or LINE D are uncommented it crashes.
> if then either
> in LINE A the "2.0 + 1.0" is changed to "2.0 + aValueThatIsNot 1.0" (eg "2.0 + 1.0001")
> or
> LINE B is removed
> then it works
>
> btw, i know that the
> float my = resolution.y;
> if (y <= my) {
> does not make sense, this is just a broken down version to have a crashing code ;)
>
> any ideas?
Yes you may report this shader and example code to Nvidia in combination with the GPU driver version used and they may fix the crash inside their GPU Shader compiler.
Bugs like this one are fixed by installing the latest stable driver from your GPU vendor.
>
>
>
> #ifdef GL_ES
> precision mediump float;
> #endif
>
> uniform vec2 resolution;
> uniform vec2 mouse;
> uniform float time;
>
> void main(void) {
> vec2 p = 2.0 * (gl_FragCoord.xy / resolution.xy) - 1.0;
> p.x *= resolution.x / resolution.y;
>
> float r = 0.0;
> float g = 0.0;
> float b = 0.0;
>
> const float ni = 9.0;
> float cw = resolution.x / (ni + 1.0);
> float ch = 2.0;
>
> float x = gl_FragCoord.x;
> float y = gl_FragCoord.y;
>
> for (float i = 1.0; i <= ni; i += 1.0) {
> float cx = i * cw + cw / 2.0;
> float dx = x - cx;
> float my = resolution.y;
> if (y <= my) {
> float dy = my / resolution.y;
> float yy = y / resolution.y;
> float ww = (cw / 2.0 - abs(dx)) * 0.1;
> float wmul = abs(sin((p.y * 2.0 + 1.0) * ch)); // <<< LINE A
> ww *= wmul; // <<< LINE B
> float c = clamp(ww, 0.0, 1.0);
> yy = clamp(yy, 0.0, 1.0);
> // r += c * yy; // <<< LINE C
> // g += c * (1.0 - yy); // <<< LINE D
> }
> }
>
> gl_FragColor = vec4(r, g, b, 1.0);
> }
>
>
>
>
> # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x61d81186, pid=2612, tid=4044
> ...
> # C [nvoglv32.dll+0x2f1186]
The shaders is compiled and in use by your graphicscard driver, if you observe the stack trace you can see that its not the JVM that crash, the crash is from inside your nvidia nvoglv32.dll GPU driver when you driver is exposed to your use case:
All the top C stack frames are from inside your nvoglv32.dll GPU driver.
> Stack: [0x002d0000,0x00320000], sp=0x003168b8, free space=282k
> Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
> C [nvoglv32.dll+0x2f1186]
> C [nvoglv32.dll+0x3b66ea]
> C [nvoglv32.dll+0x3b8290]
> C [nvoglv32.dll+0x3b9d97]
> C [nvoglv32.dll+0x3b9fee]
> C [nvoglv32.dll+0x3ba0b8]
> C [nvoglv32.dll+0x4a8434]
> C [nvoglv32.dll+0x4f25bf]
> C [nvoglv32.dll+0x4f4649]
> C [nvoglv32.dll+0x529342]
> C [nvoglv32.dll+0x5db213]
> C [nvoglv32.dll+0x5b33f6]
> C [nvoglv32.dll+0x5bf246]
> C [nvoglv32.dll+0x8bac02] DrvPresentBuffers+0x2b402
> C [nvoglv32.dll+0x8baf48] DrvPresentBuffers+0x2b748
> C [nvoglv32.dll+0x986004] DrvPresentBuffers+0xf6804
> C [nvoglv32.dll+0x987446] DrvPresentBuffers+0xf7c46
> C [nvoglv32.dll+0x8d3f6e] DrvPresentBuffers+0x4476e
> C [nvoglv32.dll+0x8d40b9] DrvPresentBuffers+0x448b9
> C [nvoglv32.dll+0x8d41a0] DrvPresentBuffers+0x449a0
> C [nvoglv32.dll+0x9876c7] DrvPresentBuffers+0xf7ec7
> C [nvoglv32.dll+0x98f35e] DrvPresentBuffers+0xffb5e
> C [nvoglv32.dll+0x1c68]
> C [nvoglv32.dll+0x16fb]
> C [nvoglv32.dll+0x14a7af]
> C [nvoglv32.dll+0x992d65] DrvPresentBuffers+0x103565
> C [nvoglv32.dll+0x1cb7bf]
> C [jogl_desktop.dll+0x3543] Java_jogamp_opengl_gl4_GL4bcImpl_dispatch_1glBegin1__IJ+0xf
> J jogamp.opengl.gl4.GL4bcImpl.dispatch_glBegin1(IJ)V
> J jogamp.opengl.gl4.GL4bcImpl.glBegin(I)V
> J main.Main.display(Ljavax/media/opengl/GLAutoDrawable;)V
> j jogamp.opengl.GLDrawableHelper.invokeGL(Ljavax/media/opengl/GLDrawable;Ljavax/media/opengl/GLContext;Ljava/lang/Runnable;Ljava/lang/Runnable;)V+83
> J com.jogamp.newt.opengl.GLWindow.display()V
> j main.Main.main([Ljava/lang/String;)V+3