Hi all,
i'm using EGL image and deleting the texture i'm facing a seg fault.
the creation of the texture and the eglImage is working fine and i'm able to use it without any problem.
At the end of my application i'm doing the following code sequence:
s_gl.glDeleteTextures(1, &tex);
s_egl.eglDestroyImageKHR(fb->getDisplay(), m_blitEGLImage);
blitEGLImage is the eglImage associated with tex. The delete seems to work fine but when i'm executing the eglDestroyImage i'm facing the seg fault:
I/DEBUG ( 287): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000
I/DEBUG ( 287): r0 671f0008 r1 671723c8 r2 66f72dd4 r3 00000000
I/DEBUG ( 287): r4 671723c8 r5 6710c218 r6 66f64d71 r7 671723c8
I/DEBUG ( 287): r8 00000002 r9 00100000 sl 67177bb8 fp 00000001
I/DEBUG ( 287): ip 67173620 sp 6e636aa0 lr 66f64d7f pc 00000000 cpsr 20000010
I/DEBUG ( 287): d0 4406e000c45e0000 d1 445e000000000001
I/DEBUG ( 287): d2 0000000200000001 d3 4000000040200000
I/DEBUG ( 287): d4 0000000441000000 d5 4e880e0044070000
I/DEBUG ( 287): d6 4406e00044070000 d7 c45e0000445de000
I/DEBUG ( 287): d8 0000000000000000 d9 0000000000000000
I/DEBUG ( 287): d10 0000000000000000 d11 0000000000000000
I/DEBUG ( 287): d12 0000000000000000 d13 0000000000000000
I/DEBUG ( 287): d14 0000000000000000 d15 0000000000000000
I/DEBUG ( 287): d16 0000000000000512 d17 0000000000000001
I/DEBUG ( 287): d18 0000000000000000 d19 0000000100000000
I/DEBUG ( 287): d20 0000000000000000 d21 0000000000000000
I/DEBUG ( 287): d22 0000000000000017 d23 00000000ffffffff
I/DEBUG ( 287): d24 1f1f1f1f1f1f1f1f d25 1f1f1f1f1f1f1f1f
I/DEBUG ( 287): d26 1f1f1f1f1f1f1f1f d27 9999999999999999
I/DEBUG ( 287): d28 0100010001000100 d29 0100010001000100
I/DEBUG ( 287): d30 9999999999999999 d31 9999999999999999
I/DEBUG ( 287): scr 20000010
I/DEBUG ( 287):
I/DEBUG ( 287): backtrace:
I/DEBUG ( 287): #00 pc 00000000 <unknown>
I/DEBUG ( 287): #01 pc 00023d7d /system/lib/egl/libGLESv1_CM_adreno200.so
I/DEBUG ( 287): #02 pc 00018e04 /system/lib/egl/libEGL_adreno200.so (egliDoDestroyEGLImage+492)
I/DEBUG ( 287): #03 pc 00012dc0 /system/lib/egl/libEGL_adreno200.so (qeglDrvAPI_eglDestroyImageKHR+316)
I/DEBUG ( 287): #04 pc 00006348 /system/lib/egl/libEGL_adreno200.so (eglDestroyImageKHR+16)
I/DEBUG ( 287): #05 pc 0000b4eb /system/lib/libEGL.so (eglDestroyImageKHR+42)
Do i miss something deleting texture and eglImage or am i missing a command or is there a known issue ?
Thanks for your help.
BR
Seb
Hi,
After investigation it seems to me that Adreno stack is automatically calling eglDestroyImageKHR when deleting the last reference onto the image. Instead of letting the Image "orphan" and then destroyed by the user calling eglDestroyImageKHR, the stack do it by itself.
The Spec is not describing such behavior and other GPU stacks seems not to operate like that.
In my case i removed the call to eglDestroyImageKHR after the call to glDeleteTextures in case of Adreno stack, assuming the Destroy call is done by the stack.
BR
Seb
Hi Sebastian..
Can you let me know how the texture is created?
http://www.khronos.org/registry/egl/extensions/KHR/EGL_KHR_image_base.txt
Seems like eglCreateImageKHR and eglDestroyImageKHR should be matched up
-mark
Hi Mark,
thanks for looking at my problem.
The Creation is done as follow:
glGenTextures(1, &m_tex);
glBindTexture(GL_TEXTURE_2D, m_tex);
char *zBuff = new char[4*p_width*p_height];
memset(zBuff, 0, 4*p_width*p_height);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
p_width, p_height, 0,
GL_RGBA, GL_UNSIGNED_BYTE, zBuff);
delete [] zBuff;
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
m_eglImage = eglCreateImageKHR(getDisplay(),
eglGetCurrentContext(),
EGL_GL_TEXTURE_2D_KHR,
(EGLClientBuffer)m_tex,
NULL);
the destruction done as follow:
glDeleteTextures(1, &m_tex);
if(isAdrenoGPU()) {
//For Adreno when it detects that we are deleteing the last reference
//on EGLImage, instead of letting it orphan it automatically calls
//eglDestroyImageKHR. So we need to bypass the explicite eglDestroyImageKHR
//we try to perform ourself to avoid seg fault
m_eglImage = 0;
}
if (m_eglImage) {
eglDestroyImageKHR(getDisplay(), m_eglImage);
}
As you can see, in case of Adreno GPU i had to bypass the eglDestroyImageKHR forcing m_eglImage to 0 . If i don't do that then there is a crash in eglDestroyImageKHR.
I also tried to switch the glDeleteTextures and eglDestroyImage doing first the eglDestroy then the glDeleteTextures in that case eglDestroyImageKHR is fine (no crash) and the glDeleteTextures crash doing an eglDestroyImageKHR (as seen in the stack trace).
It is why i arrived to the conclusion that the eglDestroy was called automatically by Adreno stack when doing the glDeleteTextures.
I also discovered that the memory is not given to the system just after the textures are deleted, the stack seems to keep the memory for a while and then give it back but i don't know on which event or event if it is possible to force the stack to give it back.
Thanks for your help and Best regards,
Seb