[SOLVED] Qt app crashing calling QPainter begin() - segfaults internally calling glCreateShader
-
I started testing my app on another machine, where I started booting it through pyside--if that makes a difference to this particular problem. Anyway, the program enters the paint() function of my QGLWidget-derived class and dies after calling begin(). Looking at the stack trace, the program is exiting inside the begin() function, where it seems to be calling glCreateShader().
@void PanelGL::paintGL()
{
QPainter painter;
painter.begin(this); // crash here calling glCreateShader inside the Qt library
...
}@If I comment out this code, I can call basic GL functions like glBegin() and glEnd(), but not higher profile calls like glCreateShader(), which also segfault. I'm already calling glewInit. If Qt's QPainter internally calls glCreateShader(), I wouldn't expect I would need to do anything involving OpenGL to make the begin() function work. Unless a QPainter() only works in a QGLWidget under certain profiles?
Here's the stack trace:
@#0 0x00007fffebdb311e in glCreateShader () from /usr/lib64/libGL.so
#1 0x00000037ba268262 in ?? () from /usr/lib64/libQtOpenGL.so.4
#2 0x00000037ba268a28 in
QGLShader::QGLShader(QFlagsQGLShader::ShaderTypeBit, QGLContext
const*, QObject*) ()
from /usr/lib64/libQtOpenGL.so.4
#3 0x00000037ba27f199 in
QGLEngineSharedShaders::QGLEngineSharedShaders(QGLContext const*) ()
from /usr/lib64/libQtOpenGL.so.4
#4 0x00000037ba27fcd8 in
QGLEngineSharedShaders::shadersForContext(QGLContext const*) ()
from /usr/lib64/libQtOpenGL.so.4
#5 0x00000037ba27fdac in
QGLEngineShaderManager::QGLEngineShaderManager(QGLContext*) ()
from /usr/lib64/libQtOpenGL.so.4
#6 0x00000037ba282fb8 in QGL2PaintEngineEx::begin(QPaintDevice*) ()
from /usr/lib64/libQtOpenGL.so.4
#7 0x00000037b97152e0 in QPainter::begin(QPaintDevice*) () from
/usr/lib64/libQtGui.so.4
#8 0x00007fffef9c402d in PanelGL::paintGL (this=0x1006030) at panelgl.cpp:117
#9 0x00000037ba22da60 in QGLWidget::glDraw() () from
/usr/lib64/libQtOpenGL.so.4
#10 0x00000037ba22d3f9 in QGLWidget::paintEvent(QPaintEvent*) () from
/usr/lib64/libQtOpenGL.so.4
#11 0x00000037b9619fdc in QWidget::event(QEvent*) () from
/usr/lib64/libQtGui.so.4
#12 0x00000037ba22f988 in QGLWidget::event(QEvent*) () from
/usr/lib64/libQtOpenGL.so.4
#13 0x00000037b95c9994 in QApplicationPrivate::notify_helper(QObject*,
QEvent*) () from /usr/lib64/libQtGui.so.4
#14 0x00000037b95ce813 in QApplication::notify(QObject*, QEvent*) ()
from /usr/lib64/libQtGui.so.4
#15 0x00007ffff024b5b6 in ?? () from
/usr/lib64/python2.7/site-packages/PySide/QtGui.so
#16 0x00000037b8f7903c in QCoreApplication::notifyInternal(QObject*,
QEvent*) () from /usr/lib64/libQtCore.so.4
#17 0x00000037b9615c80 in QWidgetPrivate::drawWidget(QPaintDevice*,
QRegion const&, QPoint const&, int, QPainter*, QWidgetBackingStore*)
() from /usr/lib64/libQtGui.so.4
#18 0x00000037b97dc867 in QWidgetPrivate::repaint_sys(QRegion const&)
() from /usr/lib64/libQtGui.so.4
#19 0x00000037b960c3e4 in QWidgetPrivate::syncBackingStore() () from
/usr/lib64/libQtGui.so.4
#20 0x00000037b961a4fc in QWidget::event(QEvent*) () from
/usr/lib64/libQtGui.so.4
#21 0x00000037ba22f988 in QGLWidget::event(QEvent*) () from
/usr/lib64/libQtOpenGL.so.4
#22 0x00000037b95c9994 in QApplicationPrivate::notify_helper(QObject*,
QEvent*) () from /usr/lib64/libQtGui.so.4
#23 0x00000037b95ce813 in QApplication::notify(QObject*, QEvent*) ()
from /usr/lib64/libQtGui.so.4
#24 0x00007ffff024b5b6 in ?? () from
/usr/lib64/python2.7/site-packages/PySide/QtGui.so
#25 0x00000037b8f7903c in QCoreApplication::notifyInternal(QObject*,
QEvent*) () from /usr/lib64/libQtCore.so.4
#26 0x00000037b8f7caca in
QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*)
()
from /usr/lib64/libQtCore.so.4
#27 0x00000037b8fa7923 in ?? () from /usr/lib64/libQtCore.so.4
#28 0x0000003039444a7d in g_main_context_dispatch () from
/lib64/libglib-2.0.so.0
#29 0x0000003039445278 in ?? () from /lib64/libglib-2.0.so.0
#30 0x000000303944544c in g_main_context_iteration () from
/lib64/libglib-2.0.so.0
#31 0x00000037b8fa7d4f in
QEventDispatcherGlib::processEvents(QFlagsQEventLoop::ProcessEventsFlag)
()
from /usr/lib64/libQtCore.so.4
#32 0x00000037b966c61e in ?? () from /usr/lib64/libQtGui.so.4
#33 0x00000037b8f78172 in
QEventLoop::processEvents(QFlagsQEventLoop::ProcessEventsFlag) ()
from /usr/lib64/libQtCore.so.4 @ -
Any updates on this issue?
-
I doubt that there will be any without "a bug report":http://bugreports.qt.nokia.com/:-(
-
I had a "similar problem":http://gamedev.stackexchange.com/questions/22785/glcreateshader-causes-segmentation-fault once and here is how I solved it: before calling glCreateShader(), which is a GLEW function, I needed to initialize the library and I wasn't doing so.
@
GLenum err = glewInit();
if (err != GLEW_OK)
{
qDebug() << "paintEvent !!! glewInit failed with: " << err;
return;
}
if (!GLEW_VERSION_2_1) // check that the machine supports the 2.1 API.
{
qDebug() << "paintEvent !!! System doesn't support GLEW_VERSION_2_1";
return;
}
@Apparently, the problem reported in this thread was not caused by this issue because the user is already calling glewInit().
-
[quote author="karlphillip" date="1327328408"]
I'm afraid this is not a Qt bug. It seems that strattonbrazil is trying to call glCreateShader(), which is a GLEW function, without initializing this library first.
@[/quote]Hey Karl,
That's an interesting assumption considering that I say in my original post "I’m already calling glewInit". Anyway, if QPainter is calling glCreateShader, Qt should be calling glewInit unless Qt is shipping without libraries that it needs to perform basic operations under the hood like creating a QPainter inside a QGLWidget.
The problem was that in Qt Creator, the default run settings on my new OS set the LD_LIBRARY_PATH, which caused a consistent segfault. I could replicate this on the shell too by setting the same variable. By changing my run settings from "build" to "system" it worked fine.
-
Thank you for the feedback. I updated my answer.
Now that you solved the problem you can add [Solved] in the beggining of the title of the question.