BadMatch (X_GLXMakeContextCurrent) segfault on rendering
Describe the bug Rendering appears to be segfaulting for perhaps a few weeks or more. It occurs using system or packaged SDL, Wayland and X(Wayland), Vulkan and GL.
Other apps are behaving normally, including SDL2 titles on Vulkan or GL.
To Reproduce Steps to reproduce the behavior: Configure:
CMAKE_SHARED_LINKER_FLAGS:STRING=-Wl,--no-undefined
BUILD_SHARED_LIBS:BOOL=0
CMAKE_CXX_FLAGS:STRING=-ferror-limit=0
CMAKE_C_FLAGS:STRING=-ferror-limit=0
CMAKE_EXE_LINKER_FLAGS_INIT:STRING=-fuse-ld=lld
CMAKE_SHARED_LINKER_FLAGS_INIT:STRING=-fuse-ld=lld
CMAKE_MODULE_LINKER_FLAGS_INIT:STRING=-fuse-ld=lld
USE_STATIC_LIBCXX:BOOL=1
FILAMENT_ENABLE_MATDBG:BOOL=0
FILAMENT_BUILD_FILAMAT:BOOL=1
FILAMENT_DISABLE_MATOPT:BOOL=0
FILAMENT_MIN_COMMAND_BUFFERS_SIZE_IN_MB:UNINITIALIZED=20
FILAMENT_ENABLE_LTO:BOOL=0
BUILD_TESTING:BOOL=0
FILAMENT_SKIP_SAMPLES:BOOL=0
CMAKE_POSITION_INDEPENDENT_CODE:BOOL=1
FILAMENT_SKIP_SDL2:BOOL=0
FILAMENT_SUPPORTS_WAYLAND:BOOL=0
FILAMENT_SUPPORTS_VULKAN:BOOL=0
FILAMENT_SUPPORTS_OPENGL:BOOL=1
FILAMENT_SUPPORTS_XCB:BOOL=1
FILAMENT_SUPPORTS_XLIB:BOOL=1
Logs
./hellotriangle
FEngine (64 bits) created at 0x555556983e90 (threading is enabled)
FEngine resolved backend: OpenGL
[NVIDIA Corporation], [NVIDIA GeForce GTX 1080 Ti/PCIe/SSE2], [4.1.0 NVIDIA 550.90.07], [4.10 NVIDIA via Cg compiler]
Feature level: 1
Active workarounds:
allow_read_only_ancillary_feedback_loop
GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT = 16
GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS = 192
GL_MAX_DRAW_BUFFERS = 8
GL_MAX_RENDERBUFFER_SIZE = 32768
GL_MAX_SAMPLES = 32
GL_MAX_TEXTURE_IMAGE_UNITS = 32
GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS = 4
GL_MAX_UNIFORM_BLOCK_SIZE = 65536
GL_MAX_UNIFORM_BUFFER_BINDINGS = 84
GL_NUM_PROGRAM_BINARY_FORMATS = 1
GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT = 256
OS version: 0
Backend feature level: 1
FEngine feature level: 0
X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 150 (GLX)
Minor opcode of failed request: 26 (X_GLXMakeContextCurrent)
Serial number of failed request: 28
Current serial number in output stream: 28
Desktop OS: Arch Linux GPU: NVIDIA GTX 1080 Backend: OpenGL and Vulkan
Additional context I was unable to find this issue Open, though there have been some similar issues closed.
I verified cmake invocation.. Here is a Debug build which did output more info.
lldb ./gltf_viewer -- -a opengl
(lldb) target create "./gltf_viewer"
Current executable set to 'build/filament/Debug/samples/gltf_viewer' (x86_64).
(lldb) settings set -- target.run-args "-a" "opengl"
(lldb) run
Process 5249 launched: '/mnt/g/dev/build/filament/Debug/samples/gltf_viewer' (x86_64)
FEngine (64 bits) created at 0x5555590144d0 (threading is enabled)
FEngine resolved backend: OpenGL
[NVIDIA Corporation], [NVIDIA GeForce GTX 1080 Ti/PCIe/SSE2], [4.1.0 NVIDIA 550.90.07], [4.10 NVIDIA via Cg compiler]
Feature level: 1
Active workarounds:
allow_read_only_ancillary_feedback_loop
GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT = 16
GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS = 192
GL_MAX_DRAW_BUFFERS = 8
GL_MAX_RENDERBUFFER_SIZE = 32768
GL_MAX_SAMPLES = 32
GL_MAX_TEXTURE_IMAGE_UNITS = 32
GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS = 4
GL_MAX_UNIFORM_BLOCK_SIZE = 65536
GL_MAX_UNIFORM_BUFFER_BINDINGS = 84
GL_NUM_PROGRAM_BINARY_FORMATS = 1
GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT = 256
OS version: 0
Backend feature level: 1
FEngine feature level: 1
Requested linear format but KTX contains a sRGB format.
Requested linear format but KTX contains a sRGB format.
Texture Decoder has 6 background threads.
X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 150 (GLX)
Minor opcode of failed request: 26 (X_GLXMakeContextCurrent)
Serial number of failed request: 28
Current serial number in output stream: 28
PanicLog
in void utils::panic(const char *, const char *, int, const char *):34
in file filament/libs/utils/src/debug.cpp
reason: filament/filament/backend/include/private/backend/CommandStream.h:285: failed assertion 'utils::ThreadUtils::isThisThread(mThreadId)'
#0 gltf_viewer 0x55555839b04d (null) + 93825040756813
#1 gltf_viewer 0x55555839b019 (null) + 93825040756761
#2 gltf_viewer 0x5555583b0c7b (null) + 93825040845947
#3 gltf_viewer 0x555558398698 (null) + 93825040746136
#4 gltf_viewer 0x55555811214e (null) + 93825038098766
#5 gltf_viewer 0x55555811a124 (null) + 93825038131492
#6 gltf_viewer 0x5555581198b0 (null) + 93825038129328
#7 gltf_viewer 0x55555812404a (null) + 93825038172234
#8 gltf_viewer 0x555558109fdd (null) + 93825038065629
#9 gltf_viewer 0x5555581099b6 (null) + 93825038064054
#10 gltf_viewer 0x5555581094a9 (null) + 93825038062761
#11 gltf_viewer 0x55555814c819 (null) + 93825038338073
#12 gltf_viewer 0x5555580e83f6 (null) + 93825037927414
#13 gltf_viewer 0x555557edfd10 (null) + 93825035795728
#14 gltf_viewer 0x555556f1356b (null) + 93825019229547
#15 gltf_viewer 0x555556f11b8c (null) + 93825019222924
#16 gltf_viewer 0x555556f11239 (null) + 93825019220537
#17 gltf_viewer 0x555556f0b428 (null) + 93825019196456
Process 5249 stopped
* thread #8, name = 'FEngine::loop', stop reason = signal SIGABRT
frame #0: 0x00007ffff7d50e44 libc.so.6`___lldb_unnamed_symbol3665 + 276
libc.so.6`___lldb_unnamed_symbol3665:
-> 0x7ffff7d50e44 <+276>: movl %eax, %ebx
0x7ffff7d50e46 <+278>: negl %ebx
0x7ffff7d50e48 <+280>: cmpl $0xfffff000, %eax ; imm = 0xFFFFF000
0x7ffff7d50e4d <+285>: movl $0x0, %eax
For context, https://github.com/google/filament/issues/7560 Removing the thread ID check, the samples still crash but for some reason lack debug symbols there.
I'm pretty sure this is due to the switch of many Linux distros to set Wayland as default. You can try switching to Xorg to verify.
I don't know if the problem exists with Wayland, but this one I recall does.
wl_proxy_get_version@0x00007ffff7f41cc4 (??:-1)
wl_shell_get_shell_surface@0x00005555564450e1 (build/filament/Debug/autogen/wayland/wayland-client-protocol.h:3166)
Wayland_CreateWindow@0x0000555556444d5d (filament/third_party/libsdl2/src/video/wayland/SDL_waylandwindow.c:424)
SDL_CreateWindow_REAL@0x000055555635db91 (filament/third_party/libsdl2/src/video/SDL_video.c:1475)
SDL_CreateWindow@0x0000555556282d5b (filament/third_party/libsdl2/src/dynapi/SDL_dynapi_procs.h:542)
FilamentApp::Window::Window(FilamentApp*, Config const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, unsigned long, unsigned long)@0x0000555555f886e8 (filament/libs/filamentapp/src/FilamentApp.cpp:607)
FilamentApp::run(Config const&, std::__1::function<void (filament::Engine*, filament::View*, filament::Scene*)>, std::__1::function<void (filament::Engine*, filament::View*, filament::Scene*)>, std::__1::function<void (filament::Engine*, filament::View*)>, std::__1::function<void (filament::Engine*, filament::View*, filament::Scene*, filament::Renderer*)>, std::__1::function<void (filament::Engine*, filament::View*, filament::Scene*, filament::Renderer*)>, unsigned long, unsigned long)@0x0000555555f84362 (filament/libs/filamentapp/src/FilamentApp.cpp:125)
main@0x0000555555f34224 (filament/samples/hellotriangle.cpp:189)
___lldb_unnamed_symbol3256@0x00007ffff7c8bc88 (??:-1)
__libc_start_main@0x00007ffff7c8bd4c (??:-1)
_start@0x0000555555f33ec5 (??:-1)
and considering this https://github.com/google/filament/issues/6094 I'll continue to look, maybe try with newer SDL.
For another idea of hacking/testing, you could try changing this line: https://github.com/google/filament/blob/main/CMakeLists.txt#L34C8-L34C33
to
option(FILAMENT_SUPPORTS_WAYLAND "Include Wayland support in Linux builds" ON)
Success! using current system SDL and FILAMENT_SKIP_SDL2. Thank you for your attention.