Segfault when using VTK inside docker with EGL - regression

I am running a C++ app that uses VTK compiled with VTK_OPENGL_HAS_EGL=ON inside a docker container with nvidia container runtime.

This was working fine with a previous build (git hash 55b8be80a79daa81e57b4e229671c8b1cdcaab1b), but when I update to VTK 9.5.0 (git hash 13acb1a5dd0ad7f7635f2511f44e599733643d06) my application segfaults:

Stacktrace:
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `./myapp'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x0000000000000000 in ?? ()
[Current thread is 1 (Thread 0x7feab487b000 (LWP 27))]
(gdb) bt 10
#0  0x0000000000000000 in ?? ()
#1  0x00007feabbf5f181 in vtkEGLRenderWindow::SetDeviceAsDisplay(int) ()
   from /opt/myapp_lib/usr/local/lib/libvtkRenderingOpenGL2-9.5.so.1
#2  0x00007feabbf60031 in vtkEGLRenderWindow::ResizeWindow(int, int) ()
   from /opt/myapp_lib/usr/local/lib/libvtkRenderingOpenGL2-9.5.so.1
#3  0x00007feabbf6011a in vtkEGLRenderWindow::WindowInitialize() ()
   from /opt/myapp_lib/usr/local/lib/libvtkRenderingOpenGL2-9.5.so.1
#4  0x00007feabbe9d84f in vtkOpenGLRenderWindow::Start() ()
   from /opt/myapp_lib/usr/local/lib/libvtkRenderingOpenGL2-9.5.so.1
#5  0x00007feabb1ff9d5 in vtkRenderWindow::Render() ()
   from /opt/myapp_lib/usr/local/lib/libvtkRenderingCore-9.5.so.1
#6  0x00007feabbea31ff in vtkOpenGLRenderWindow::Render() ()
   from /opt/myapp_lib/usr/local/lib/libvtkRenderingOpenGL2-9.5.so.1
#7  0x000055be4eff0eb5 in VtkRenderPipeline::Render(std::shared_ptr<PipelineRun>) ()

@jaswantp

13acb1a5dd0ad7f7635f2511f44e599733643d06 corresponds to v9.4.2, sure you’re on v9.5.0?

In any case, would it be possible for you to build VTK with debug info? The best thing to do is set a breakpoint at vtkEGLRenderWindow::SetDeviceAsDisplay, step into the function and execute it line by line to figure out where it crashed. Would also be nice to see the list output of info shared in gdb.

I believe people had VTK 9.5.0 successfully use EGL from docker containers with nvidia-container runtime.

Yes apologies, I meant 9.5.0 (e70c856bd9122ad759921c61d86a153e0311e20d).

I did also try 9.4.2 to see if I could bisect the issue but ran into some build errors with nlohmann::json, I think because my app pulled in a different version of it from vcpkg.

info shared:

From                To                  Syms Read   Shared Object Library
0x00007feabe9fbd20  0x00007feabea04e39  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkRenderingGL2PSOpenGL2-9.5.so.1
0x00007feabe96cac0  0x00007feabe9c9476  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkRenderingVolumeOpenGL2-9.5.so.1
0x00007feabd71f3a0  0x00007feabe5ab164  Yes         /opt/myapp_lib/usr/local/lib/libonnxruntime.so.1
0x00007feabd6731c0  0x00007feabd673638  Yes (*)     /usr/lib/x86_64-linux-gnu/libOpenGL.so.0
0x00007feabd62c700  0x00007feabd646371  Yes (*)     /usr/lib/x86_64-linux-gnu/libGLX.so.0
0x00007feabcf38c20  0x00007feabd4ab345  Yes (*)     /opt/myapp_lib/usr/local/lib/libopencv_dnn.so.412
0x00007feabc095500  0x00007feabcbecb5c  Yes (*)     /opt/myapp_lib/usr/local/lib/libopencv_core.so.412
0x00007feabbd51790  0x00007feabbf688f7  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkRenderingOpenGL2-9.5.so.1
0x00007feabbc5a2e0  0x00007feabbc7b8ef  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkglad-9.5.so.1
0x00007feabbbcbf60  0x00007feabbbe9f69  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkInteractionStyle-9.5.so.1
0x00007feabb5a60e0  0x00007feabb9b5f19  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkRenderingVolume-9.5.so.1
0x00007feabb3d23b0  0x00007feabb542ef2  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkIOImage-9.5.so.1
0x00007feabb2f67a0  0x00007feabb30abc9  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkRenderingFreeType-9.5.so.1
0x00007feabb0f8000  0x00007feabb2727f4  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkRenderingCore-9.5.so.1
0x00007feabb030cc0  0x00007feabb0410bb  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkCommonColor-9.5.so.1
0x00007feabad24220  0x00007feabaff26c9  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkImagingCore-9.5.so.1
0x00007feabac2ed60  0x00007feabaca6679  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkCommonExecutionModel-9.5.so.1
0x00007feaba6d8270  0x00007feabaac0923  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkCommonDataModel-9.5.so.1
0x00007feaba5647a0  0x00007feaba58f854  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkCommonTransforms-9.5.so.1
0x00007feab90814b0  0x00007feaba0e6c09  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkCommonCore-9.5.so.1
0x00007feab8d76c60  0x00007feab8dae50c  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtksys-9.5.so.1
0x00007feab8b8c5c0  0x00007feab8ccbce2  Yes (*)     /usr/lib/x86_64-linux-gnu/libstdc++.so.6
0x00007feab8a0e420  0x00007feab8a8c3a6  Yes         /usr/lib/x86_64-linux-gnu/libm.so.6
0x00007feab89d4780  0x00007feab89f7745  Yes (*)     /usr/lib/x86_64-linux-gnu/libgcc_s.so.1
0x00007feab87e6800  0x00007feab896dcb9  Yes         /usr/lib/x86_64-linux-gnu/libc.so.6
0x00007feabea25000  0x00007feabea4f195  Yes         /lib64/ld-linux-x86-64.so.2
0x00007feab87a1560  0x00007feab87b4246  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkgl2ps-9.5.so.1
0x00007feab8780540  0x00007feab8796b82  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkCommonMath-9.5.so.1
0x00007feab87328a0  0x00007feab876a879  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkImagingMath-9.5.so.1
0x00007feab8183160  0x00007feab862d972  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkFiltersGeneral-9.5.so.1
0x00007feab7607e20  0x00007feab7f398d9  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkFiltersCore-9.5.so.1
0x00007feab75107e0  0x00007feab751e68e  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkCommonSystem-9.5.so.1
0x00007feab719a030  0x00007feab73a76d9  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkCommonMisc-9.5.so.1
0x00007feab701b2c0  0x00007feab701d42f  Yes (*)     /usr/lib/x86_64-linux-gnu/libGLdispatch.so.0
0x00007feab6eb7100  0x00007feab6f45fde  Yes (*)     /usr/lib/x86_64-linux-gnu/libX11.so.6
0x00007feab5474fc0  0x00007feab6c40ca7  Yes (*)     /opt/myapp_lib/usr/local/lib/libopencv_imgproc.so.412
0x00007feab53c9260  0x00007feab53dac40  Yes (*)     /usr/lib/x86_64-linux-gnu/libz.so.1
0x00007feab53bf9c0  0x00007feab53c2629  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkRenderingHyperTreeGrid-9.5.so.1
0x00007feab53abdc0  0x00007feab53b324e  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkRenderingUI-9.5.so.1
0x00007feab52f2dc0  0x00007feab5378c49  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkFiltersSources-9.5.so.1
0x00007feab529bb80  0x00007feab52af89e  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkDICOMParser-9.5.so.1
0x00007feab520ac20  0x00007feab527a12d  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkmetaio-9.5.so.1
0x00007feab51a7410  0x00007feab51dbb5f  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkpng-9.5.so.1
0x00007feab5112550  0x00007feab5169479  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtktiff-9.5.so.1
0x00007feab50ed720  0x00007feab50ffb5c  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkzlib-9.5.so.1
0x00007feab50b8770  0x00007feab50dfe19  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkpugixml-9.5.so.1
0x00007feab5094a20  0x00007feab50a3f32  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtktoken-9.5.so.1
0x00007feab5007de0  0x00007feab5062827  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkjpeg-9.5.so.1
0x00007feab4f4ae20  0x00007feab4fd7c1d  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkfreetype-9.5.so.1
0x00007feab4f203a0  0x00007feab4f30879  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkCommonComputationalGeometry-9.5.so.1
0x00007feab4da7610  0x00007feab4ec890f  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkFiltersGeometry-9.5.so.1
0x00007feab4d632a0  0x00007feab4d6e1e4  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkdoubleconversion-9.5.so.1
0x00007feab4d51d10  0x00007feab4d5ae52  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkloguru-9.5.so.1
0x00007feab4d46260  0x00007feab4d496ae  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkkissfft-9.5.so.1
0x00007feab4d18690  0x00007feab4d38264  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkFiltersVerdict-9.5.so.1
0x00007feab4ce5b10  0x00007feab4cff828  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkfmt-9.5.so.1
0x00007feab4b516a0  0x00007feab4c7adeb  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkFiltersReduction-9.5.so.1
0x00007feab4adb660  0x00007feab4aedebe  Yes (*)     /usr/lib/x86_64-linux-gnu/libxcb.so.1
0x00007feab4a05320  0x00007feab4a972f9  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkFiltersHybrid-9.5.so.1
0x00007feab496c100  0x00007feab49ba905  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkFiltersHyperTree-9.5.so.1
0x00007feab490e600  0x00007feab4939001  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkverdict-9.5.so.1
0x00007feab4906360  0x00007feab4907042  Yes (*)     /usr/lib/x86_64-linux-gnu/libXau.so.6
0x00007feab48ff1a0  0x00007feab4900a89  Yes (*)     /usr/lib/x86_64-linux-gnu/libXdmcp.so.6
0x00007feab48b8ce0  0x00007feab48f3ed9  Yes (*)     /opt/myapp_lib/usr/local/lib/libvtkImagingSources-9.5.so.1
0x00007feab4899de0  0x00007feab48a44f6  Yes (*)     /usr/lib/x86_64-linux-gnu/libbsd.so.0
0x00007feab4888160  0x00007feab4890a7a  Yes (*)     /usr/lib/x86_64-linux-gnu/libmd.so.0
0x00007feaaefc5e80  0x00007feaafe5b124  Yes (*)     /usr/lib/x86_64-linux-gnu/libcuda.so.1
0x00007feab4867040  0x00007feab4867105  Yes         /usr/lib/x86_64-linux-gnu/libdl.so.2
0x00007feab4862040  0x00007feab4862105  Yes         /usr/lib/x86_64-linux-gnu/libpthread.so.0
0x00007feab485d080  0x00007feab485d2b1  Yes         /usr/lib/x86_64-linux-gnu/librt.so.1
0x00007feab4687040  0x00007feab468711f  Yes         /opt/myapp_lib/usr/local/lib/libonnxruntime_providers_shared.so
0x00007fea825c77d0  0x00007fea83497752  Yes         /opt/myapp_lib/usr/local/lib/libonnxruntime_providers_cuda.so
0x00007fea50c5a9c0  0x00007fea58818ed2  Yes (*)     /usr/local/cuda/targets/x86_64-linux/lib/libcublasLt.so.12
0x00007fea49a31360  0x00007fea49faa212  Yes (*)     /usr/local/cuda/targets/x86_64-linux/lib/libcublas.so.12
0x00007fea37c27630  0x00007fea380f7c2a  Yes (*)     /usr/local/cuda/targets/x86_64-linux/lib/libcufft.so.11
0x00007feaa060dfb0  0x00007feaa068e614  Yes (*)     /usr/local/cuda/targets/x86_64-linux/lib/libcudart.so.12
0x00007feaa0204230  0x00007feaa021448e  Yes (*)     /usr/lib/x86_64-linux-gnu/libcudnn.so.9
0x00007fea2f264fa0  0x00007fea2f4eaf62  Yes (*)     /usr/lib/x86_64-linux-gnu/libcudnn_graph.so.9.10.2
0x00007fe9fa220b10  0x00007fe9fa4a5622  Yes (*)     /usr/lib/x86_64-linux-gnu/libcudnn_ops.so.9.10.2
0x00007fe9cb3141e0  0x00007fe9ce248b02  Yes (*)     /usr/lib/x86_64-linux-gnu/libcudnn_engines_precompiled.so.9.10.2
0x00007fe9c72303f0  0x00007fe9c74a7947  Yes (*)     /usr/lib/x86_64-linux-gnu/libcudnn_heuristic.so.9.10.2
0x00007fea2d639430  0x00007fea2dd29622  Yes (*)     /usr/lib/x86_64-linux-gnu/libcudnn_engines_runtime_compiled.so.9.10.2

I’ll see if I can get a build done with debug symbols.

Interesting, all I see is GLX and no references to libEGL in that output. I suspect gladLoadEGL fails. Here’s a couple of things you can try on a release build that might fix the crash:

  1. Call interactor->Initialize() before the first Render call. I’ve seen it crash in some cases if Render is called before interactor is initialized. It happened on a NERSC cluster for @Sebastien_Jourdain
  2. If that fails, try to set the environment variable VTK_DEFAULT_EGL_DEVICE_INDEX to 1 or 2, or higher.

I tried setting VTK_DEFAULT_EGL_DEVICE_INDEX to 1, 2 and 5 and it made no difference.

I’m not using the interactor as it’s a headless application.

okay. let us know what the debug build shows.

did some investigating and i can reproduce.

I tried on a basic ubuntu image and can reproduce the segfault with nvidia container. (docker run -it --rm --runtime=nvidia --gpus all -v$PWD:/work ubuntu). Installing libegl1 with apt fixed the issue for me. It seems needed for vendor neutral GL dispatch.

I already have libegl1 installed. I’m using nvcr.io/nvidia/tensorrt:25.06-py3 as a base image with the following packages installed:

 RUN apt-get update && \
  apt-get install -y \
  libopengl0 \
  libxi6 \
  ffmpeg \
  libsm6 \
  libxext6 \
  libegl1 \
  libglvnd0 \
  libgl1 \
  libglx0 \
  libegl1 \
  libgles2

Thanks. I can reproduce the segfault if I use vtkEGLRenderWindow directly in my code. Does your code do that?

Please use the factory class vtkRenderWindow instead and let me know if that works.

Thanks Jaswant, that seems to have done the trick :slight_smile: