QOpenGL widget-based app crashing
| Affects | Status | Importance | Assigned to | Milestone | |
|---|---|---|---|---|---|
| | libhybris (Ubuntu) |
Undecided
|
Simon Fels | ||
| | qtubuntu (Ubuntu) |
High
|
Gerry Boland | ||
Bug Description
tsdgeos has this crash with a game of his: http://
| Albert Astals Cid (aacid) wrote : | #1 |
| Changed in qtubuntu: | |
| importance: | Undecided → High |
| status: | New → Triaged |
| Gerry Boland (gerboland) wrote : | #2 |
Crash only occurs on the phone, not desktop. This tends to be the usual backtrace:
Program received signal SIGSEGV, Segmentation fault.
0x00000000 in ?? ()
(gdb) bt
#0 0x00000000 in ?? ()
#1 0xb6b6af64 in glGenTextures (this=<optimized out>, textures=0x2815d8, n=1) at opengl/
#2 create (this=0x2815c8) at opengl/
#3 QOpenGLTexture:
at opengl/
#4 0xb6b70b46 in QOpenGLTexture:
at opengl/
#5 0xb6b70c66 in QOpenGLTexture:
at opengl/
#6 0x0000b480 in ?? ()
Qt has a non-trivial way of wrapping GL calls to abstract away API differences where possible. It starts in QOpenGLTextureH
http://
Here GenTextures is a function pointer:
GenTextures = ::glGenTextures;
which should be set the address of the actual call. It is via this GenTextures that Qt then works.
But when I try to debug this assignment, I get confusing results:
(gdb) p GenTextures
$3 = (void (*)(GLsizei, GLuint *)) 0xffffffff
(gdb) p glGenTextures
Cannot take address of method glGenTextures.
(gdb) p ::glGenTextures
$4 = {<text gnu-indirect-
This debug is definitely taken after the variable should be assigned. But this makes no sense.
| Gerry Boland (gerboland) wrote : | #3 |
Easy way to reproduce problem is to install qtbase5-examples and run
/usr/lib/
| Gerry Boland (gerboland) wrote : | #4 |
Digging into hybris, glGenTextures is generated by
#define GLES2_IDLOAD(sym) \
__asm__ (".type " #sym ", %gnu_indirect_
typeof(sym) * sym ## _dispatch (void) __asm__ (#sym);\
typeof(sym) * sym ## _dispatch (void) \
{ \
return (void *) android_
}
which a function that when first called overwrites it's plt entry with new address. Subsequent calls jump directly at the target function in the android library.
Qt is saving a pointer to this function, before it is ever called. Might be a problem, /me goes to learn about PLT entries
| Gerry Boland (gerboland) wrote : | #5 |
Confirmed that ::glGenTextures is resolving to 0x0 for Qt, meaning GenTextures is also null, and so QOpenGLTextureH
| Gerry Boland (gerboland) wrote : | #6 |
nm -D /usr/lib/
00002384 i glGenTextures
the symbol is in the library, but is indirect function.
LD_DEBUG=all ./cube --desktop_
8196: symbol=
8196: symbol=
8196: symbol=
8196: symbol=
8196: symbol=
8196: binding file /usr/lib/
it appears that the runtime linker finds the symbol in the correct library.
| Gerry Boland (gerboland) wrote : | #7 |
Investigating libhybris, I see no evidence for it resolving the symbol incorrectly. Enabling debug & trace modes, and patching it to print each resolved symbol and its address, I see
glGetIntegerv, (nil)
glGenTextures, (nil)
glBindTexture, (nil)
glTexImage2D, (nil)
glTexSubImage2D, (nil)
glDeleteTextures, (nil)
glGetBooleanv, (nil)
glTexParameteri, (nil)
glActiveTexture, (nil)
glPixelStorei, (nil)
glGetTexParamet
glGetTexParamet
glTexParameteriv, (nil)
glTexParameterfv, (nil)
glCompressedTex
glCompressedTex
glGenerateMipmap, (nil)
HYBRIS constructed!!
glGetString, 0xb6cdfd34
glCreateProgram, 0xb6cde208
glCreateShader, 0xb6cde220
glShaderSource, 0xb6cde7d8
glCompileShader, 0xb6cde1a4
glGetShaderiv, 0xb6cde560
glAttachShader, 0xb6cde024
glLinkProgram, 0xb6cde724
glGetProgramiv, 0xb6cde524
glUseProgram, 0xb6cdea58
glGenTextures, 0xb6cde440
// from here, Qt prints:
Helper: glGenTextures 0x0 0x0 <- should print same address as hybris just returned above
"glTexImage3D" true
"glTexSubImage3D" true
"glCompressedTe
"glCompressedTe
glGenTextures 0xdf9250 0x0
Segmentation fault (core dumped)
I had a slight concern that the log shows the first time glGenTextures symbols is asked for, the glesv2 hybris constructor had not completed, so the symbol returned is 0. But the %gnu_indirect_
| Pat McGowan (pat-mcgowan) wrote : | #8 |
@simon mind having a look when you can
| Changed in libhybris (Ubuntu): | |
| assignee: | nobody → Simon Fels (morphis) |
| Changed in qtubuntu: | |
| assignee: | nobody → Gerry Boland (gerboland) |
| Gerry Boland (gerboland) wrote : | #9 |
I suspect https:/
| Launchpad Janitor (janitor) wrote : | #10 |
Status changed to 'Confirmed' because the bug affects multiple users.
| Changed in libhybris (Ubuntu): | |
| status: | New → Confirmed |
| affects: | qtubuntu → qtubuntu (Ubuntu) |


In case you're interested at reproducing the code can be found at git://anongit. kde.org/ blinken
It compiles fine on the phone after you install the dependencies.
Also if you need help testing something do not hesitate to ask.