OpenGL segfault. Linux.

After managing to compile my code under Linux and run my application I notice that 80% of
the time I get a segfault. I investigated further with gdb and here is the gdb output:

(gdb) r
Starting program: /home/aris/Downloads/thesisBackup/qt/cmakeBuild/Bin/Mesh
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/".
[New Thread 0xb26aab40 (LWP 2823)]
[New Thread 0xb112ab40 (LWP 2824)]
[New Thread 0xb07ffb40 (LWP 2825)]
[New Thread 0xafda3b40 (LWP 2826)]
[New Thread 0xaf3ffb40 (LWP 2827)]
[New Thread 0xae9ffb40 (LWP 2828)]
Populating Context

Program received signal SIGSEGV, Segmentation fault.
0xb6688de4 in OpenGl_Workspace::AspectFace(unsigned int) ()
from /home/aris/Downloads/occ/occ-build-cmake/lin32/gcc/lib/

asking for the backtrace:

(gdb) bt
#0 0xb6688de4 in OpenGl_Workspace::AspectFace(unsigned int) ()
from /home/aris/Downloads/occ/occ-build-cmake/lin32/gcc/lib/
#1 0xb6686083 in OpenGl_Workspace::ResetAppliedAspect() ()
from /home/aris/Downloads/occ/occ-build-cmake/lin32/gcc/lib/
#2 0xb668752c in OpenGl_Workspace::Activate() ()
from /home/aris/Downloads/occ/occ-build-cmake/lin32/gcc/lib/
#3 0xb6684dec in OpenGl_Window::Init() ()
from /home/aris/Downloads/occ/occ-build-cmake/lin32/gcc/lib/
#4 0xb66856f8 in OpenGl_Window::Resize(CALL_DEF_WINDOW const&) ()
from /home/aris/Downloads/occ/occ-build-cmake/lin32/gcc/lib/
#5 0xb6659bb4 in OpenGl_GraphicDriver::ClipLimit(Graphic3d_CView const&, unsigned int) ()
from /home/aris/Downloads/occ/occ-build-cmake/lin32/gcc/lib/
#6 0xb68bba78 in Visual3d_View::SetWindow(Handle_Aspect_Window const&) ()
from /home/aris/Downloads/occ/occ-build-cmake/lin32/gcc/lib/
#7 0xb68573a9 in V3d_View::SetWindow(Handle_Aspect_Window const&) ()
from /home/aris/Downloads/occ/occ-build-cmake/lin32/gcc/lib/
#8 0x08065b87 in QtoccViewWidget::QtoccViewWidget(Handle_AIS_InteractiveContext, QWidget*) ()
#9 0x08061c58 in MainWindow::setupContainerWidget() ()
#10 0x0806191c in MainWindow::MainWindow(QWidget*) ()
#11 0x08060d0c in main ()

11-9 are calls made by my program, but 8-0 are calls made by openCASCADE. Looking at my code, I don't seem to do anything wrong. Has anyone else come across something similar?
Note that on windows the application runs 100% ok.

Aris Karagiannidis's picture

For further help, the code that I use is:

#if defined WIN32
Aspect_Handle aWindowHandle = (Aspect_Handle )winId();
Handle(WNT_Window) hWnd = new WNT_Window (aWindowHandle);
#elif defined LIN
Window aWindowHandle = (Window )winId();
Handle(Aspect_DisplayConnection) aDispConnection = myContext->CurrentViewer()->Driver()->GetDisplayConnection();
Handle(Xw_Window) hWnd = new Xw_Window (aDispConnection, aWindowHandle);
#error Supported platforms are Windows(WIN32) and Linux(LIN)

Laszlo Kudela's picture


I had the same problem. For me, the problem was that I overrode the sizeHint() method from Qt. Commenting it out fixed the problem.