Login  Register

Invalid memory acccess on texture applying issue

Posted by netzz on Sep 27, 2010; 7:38am
URL: https://forum.jogamp.org/Invalid-memory-acccess-on-texture-applying-issue-tp1587224.html

Hi!

I have an application, that should render movie to the texture or textures.

For that purpose I use GStreamer library for deconding video and JOGL for render.

Sometimes application crashes with message:

Invalid memory access of location 0x4b356010 eip=0x1d44c13f

Usually it occures on routine movie playing (applying frame byte buffer to texture), sometimes on creating texture.

There is an OS report:


OS Version:      Mac OS X 10.6.4 (10F569)
Report Version:  6

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000000432cc8e0
Crashed Thread:  18  Java: AWT-EventQueue-0

Current thread (00000000040aa400):  JavaThread "AWT-EventQueue-0" [_thread_in_native, id=-1323114496,
stack(00000000b112e000,00000000b122e000)]
Stack: [00000000b112e000,00000000b122e000]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
J  com.jogamp.opengl.impl.gl4.GL4bcImpl.dispatch_glTexSubImage2D1(IIIIIIIILjava/lang/Object;IZJ)V
J  com.jogamp.opengl.impl.gl4.GL4bcImpl.glTexSubImage2D(IIIIIIIILjava/nio/Buffer;)V
J  Renderer.display(Ljavax/media/opengl/GLAutoDrawable;)V
J  com.jogamp.opengl.impl.GLDrawableHelper.display(Ljavax/media/opengl/GLAutoDrawable;)V



Thread 18 Crashed:  Java: AWT-EventQueue-0
0   ???                           0x1ce6413f 0 + 484852031
1   libGLImage.dylib               0x0794c939 glgProcessPixelsWithProcessor + 3963
2   com.apple.GeForceGLDriver     0x8f152f89 gldModifyTexSubImage + 3769
3   GLEngine                       0x1ba15a83 glTexSubImage2D_Exec + 950
4   libGL.dylib                   0x07a0e570 glTexSubImage2D + 87
5   libjogl_desktop.jnilib         0x158a061c Java_com_jogamp_opengl_impl_gl4_GL4bcImpl_dispatch_1glTexSubImage2D1__IIIIIIIILjava_lang_Object_2IZJ + 260
6   ???                           0x08a41134 0 + 144970036
7   ???                           0x08a418c0 0 + 144971968
8   ???                           0x0894a90c 0 + 143960332
9   ???                           0x08a4084c 0 + 144967756
10  ???                           0x08803db1 0 + 142622129
11  ???                           0x0880428d 0 + 142623373
12  ???                           0x08803db1 0 + 142622129
13  ???                           0x0880428d 0 + 142623373
14  ???                           0x08a29518 0 + 144872728
15  ???                           0x089db870 0 + 144554096
16  ???                           0x08803fdd 0 + 142622685
17  ???                           0x08803db1 0 + 142622129
18  ???                           0x08803db1 0 + 142622129
19  ???                           0x08803db1 0 + 142622129
20  ???                           0x08803db1 0 + 142622129
21  ???                           0x088012d3 0 + 142611155
22  libclient.dylib               0x028a3500 JVM_Lseek + 139952
23  libclient.dylib               0x028a32a6 JVM_Lseek + 139350
24  libclient.dylib               0x028b4f3b JVM_InternString + 2123
25  libclient.dylib               0x028b4daa JVM_InternString + 1722
26  libclient.dylib               0x028b4b94 JVM_InternString + 1188
27  libclient.dylib               0x028b462f JVM_StartThread + 2239
28  libclient.dylib               0x0280f38b JNI_CreateJavaVM_Impl + 55547
29  libSystem.B.dylib             0x0064681d _pthread_start + 345
30  libSystem.B.dylib             0x006466a2 thread_start + 34




So, error happens in glTexSubImage2D, and down there is code sample where this function is in use.

Also, crash happens always when layers > 1, and byteBuffer 100% cannot be modified from other thread.
But it looks like concurrency problem.



        synchronized public void display(GLAutoDrawable drawable) {

                GL2 gl = drawable.getGL().getGL2();
                gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);


.......

                // Rotating layers

                for (Layer l: layers)
                {
                        Player player=l.getPlayer();

                        if (player!=null)
                        {
                                        Texture texture=player.getTexture();
                                        ToGlSink.GlAtom atom=player.getGsSink().getGlAtom();
                                       
                                        if (atom!=null)
                                        {
                                                if (texture == null) {
                                                        atom.byteBuffer.rewind();
                                                        System.out.println("creating texture");
                                                        texture = TextureIO.newTexture(new TextureData (null, GL2.GL_RGBA16,atom.width, atom.height, 0, GL2.GL_BGRA, GL2.GL_UNSIGNED_INT_8_8_8_8_REV, false, false, true, atom.byteBuffer, null));
                                                        texture.enable();
                                                }
                                                else {
                                                        texture.bind();
                                                        atom.byteBuffer.rewind();
                                                       
                                                        // Crash happens here

                                                        gl.glTexSubImage2D(texture.getTarget(), 0, 0, 0, atom.width, atom.height, GL2.GL_BGRA, GL2.GL_UNSIGNED_INT_8_8_8_8_REV, atom.byteBuffer);

                                                }
                                        }

                        }
                }

        }






Any help would be appreciated.