Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NixOS: qt + glx broken / segfault / "Could not initialize GLX" #85866

Open
rkoe opened this issue Apr 23, 2020 · 16 comments
Open

NixOS: qt + glx broken / segfault / "Could not initialize GLX" #85866

rkoe opened this issue Apr 23, 2020 · 16 comments
Labels

Comments

@rkoe
Copy link
Contributor

rkoe commented Apr 23, 2020

Describe the bug
It seems that all Qt-programs, using GLX are currently broken and cause a segfault:

$ designer 
qt.glx: qglx_findConfig: Failed to finding matching FBConfig (8 8 8 0)
qt.glx: qglx_findConfig: Failed to finding matching FBConfig (1 8 8 0)
qt.glx: qglx_findConfig: Failed to finding matching FBConfig (1 1 8 0)
qt.glx: qglx_findConfig: Failed to finding matching FBConfig (1 1 1 0)
qt.glx: qglx_findConfig: Failed to finding matching FBConfig (1 1 1 0)
qt.glx: qglx_findConfig: Failed to finding matching FBConfig (8 8 8 0)
qt.glx: qglx_findConfig: Failed to finding matching FBConfig (1 8 8 0)
qt.glx: qglx_findConfig: Failed to finding matching FBConfig (1 1 8 0)
qt.glx: qglx_findConfig: Failed to finding matching FBConfig (1 1 1 0)
qt.glx: qglx_findConfig: Failed to finding matching FBConfig (1 1 1 0)
Could not initialize GLX
Aborted (core dumped)

(I guess this occurs since 20.03 since some programs worked before, but I'm not completely sure.)

This may be related to #82959 but I'm not sure and since GL with Nix-packages on non-NixOS is quite different, I'm opening a new, NixOS-related bug.

To Reproduce

  1. use NixOS 20.03
  2. install any Qt-program which uses GLX, e.g. openscad or qt-designer (qt5.qttools)
  3. try to start the program, e.g. openscad or designer

Expected behavior
Working program without segfault.

Metadata

  • system: "x86_64-linux"
  • host os: Linux 5.4.33, NixOS, 20.03.1445.95b9c99f6d0 (Markhor)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.3.4
  • channels(root): "nixos-20.03.1445.95b9c99f6d0"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos
@rkoe rkoe added the 0.kind: bug Something is broken label Apr 23, 2020
@mmilata
Copy link
Member

mmilata commented Apr 23, 2020

This may be related to #85865, but I'm not sure and since GL with Nix-packages on non-NixOS is quite different, I'm opening a new, NixOS-related bug.

Wrong issue number?:)

Also, I'm running 20.03 and tried openscad both from 20.03 as well as unstable channel and it does not segfault. I've got AMD GPU if that matters.

@rkoe
Copy link
Contributor Author

rkoe commented Apr 23, 2020

Wrong issue number?:)

Thanks, I've fixed the number.

Also, I'm running 20.03 and tried openscad both from 20.03 as well as unstable channel and it does not segfault. I've got AMD GPU if that matters.

I guess that it's related to the graphics driver or some opengl packages/-configuration. But I don't know which -- and it worked before the update.

@rkoe
Copy link
Contributor Author

rkoe commented Apr 24, 2020

After nix-env -u --always, OpenSCAD works again.
But the Qt designer is still broken. :(

@markuskowa
Copy link
Member

I am having the same problem with NixOS 20.03 (KDE desktop, trying to run nextcloud client). The problem can also be reproduced by just running glxinfo.

@rollf
Copy link
Contributor

rollf commented May 27, 2020

I have the same on OpenSuse with nixpkgs.

$ nix-shell -p nextcloud-client

[nix-shell:~]$ nextcloud
qt.glx: qglx_findConfig: Failed to finding matching FBConfig for QSurfaceFormat(version 2.0, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize -1, redBufferSize 1, greenBufferSize 1, blueBufferSize 1, alphaBufferSize -1, stencilBufferSize -1, samples -1, swapBehavior QSurfaceFormat::SingleBuffer, swapInterval 1, colorSpace QSurfaceFormat::DefaultColorSpace, profile  QSurfaceFormat::NoProfile)
qt.glx: qglx_findConfig: Failed to finding matching FBConfig for QSurfaceFormat(version 2.0, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize -1, redBufferSize 1, greenBufferSize 1, blueBufferSize 1, alphaBufferSize -1, stencilBufferSize -1, samples -1, swapBehavior QSurfaceFormat::SingleBuffer, swapInterval 1, colorSpace QSurfaceFormat::DefaultColorSpace, profile  QSurfaceFormat::NoProfile)
Could not initialize GLX
Aborted (core dumped)

[nix-shell:~]$ nix-instantiate --eval -E '(import <nixpkgs> {}).lib.version'
"20.09pre221814.10100a97c89"

[nix-shell:~]$ glxinfo | head # runs just fine
name of display: :0
display: :0  screen: 0
direct rendering: Yes
server glx vendor string: SGI
server glx version string: 1.4
server glx extensions:
    GLX_ARB_context_flush_control, GLX_ARB_create_context, 
    GLX_ARB_create_context_no_error, GLX_ARB_create_context_profile, 
    GLX_ARB_fbconfig_float, GLX_ARB_framebuffer_sRGB, GLX_ARB_multisample, 
    GLX_EXT_create_context_es2_profile, GLX_EXT_create_context_es_profile,

@ghost ghost mentioned this issue Jun 2, 2020
10 tasks
@pwetzel pwetzel mentioned this issue Jun 18, 2020
10 tasks
@bobismijnnaam
Copy link
Contributor

I'm also having problems that are related to this, I think. In particular, a program that uses Qt (mcrl2) gives the following errors (I include only two lines, but the first line in my snippet is repeated several times in the output):

qt.glx: qglx_findConfig: Failed to finding matching FBConfig for QSurfaceFormat(version 3.3, options QFlags<QSurfaceFormat::FormatOption>(DebugContext), depthBufferSize -1, redBufferSize 1, greenBufferSize 1, blueBufferSize 1, alphaBufferSize 0, stencilBufferSize 0, samples 1, swapBehavior QSurfaceFormat::SingleBuffer, swapInterval 1, colorSpace QSurfaceFormat::DefaultColorSpace, profile  QSurfaceFormat::CoreProfile)
No XVisualInfo for format QSurfaceFormat(version 3.3, options QFlags<QSurfaceFormat::FormatOption>(DebugContext), depthBufferSize -1, redBufferSize 1, greenBufferSize 1, blueBufferSize 1, alphaBufferSize 0, stencilBufferSize 0, samples 1, swapBehavior QSurfaceFormat::SingleBuffer, swapInterval 1, colorSpace QSurfaceFormat::DefaultColorSpace, profile  QSurfaceFormat::CoreProfile)

glxinfo also seems not to work:

$ nix-shell -p pkgs.glxinfo --run glxinfo
name of display: :1
Error: couldn't find RGB GLX visual or fbconfig

nixGLNvidia also does not resolve it for mcrl2 or glxinfo either:

$ nixGLNvidia $(nix run nixpkgs.glxinfo -c glxinfo)
Error: couldn't find RGB GLX visual or fbconfig
/home/bobe/.nix-profile/bin/nixGLNvidia: line 6: name: command not found

(mcrl2 prints nothing when used with nixGLNvidia, I think nixGLNvidia just hides the errors in that case. I also refactored the mcrl2 derivation to use wrapQtAppsHook, but the errors are still there and the application doesn't do any drawing.)

I want to add that glxinfo works fine if I install it through apt. I'm on Ubuntu 20.04. Is Qt/GL not supported by nix on Ubuntu, or is this a bug?

@StephenWithPH
Copy link
Contributor

StephenWithPH commented Sep 11, 2020

I was having vaguely similar problems. I found a solution that worked for me on a different issue:

#82959 (comment)

@bobismijnnaam
Copy link
Contributor

Thank you for the suggesting. Adding export changes the warning to:

QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
qt.qpa.backingstore: composeAndFlush: makeCurrent() failed

At least the application starts now (ltsgraph), but it doesn't display anything (i.e. it just shows whatever was on that part of the screen before the application started).

@stale
Copy link

stale bot commented Mar 16, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md and removed 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md labels Mar 16, 2021
@fricklerhandwerk
Copy link
Contributor

This is still relevant. I have the same problem on Ubuntu 20.04 with https://github.com/lopsided98/nix-ros-overlay when building ROS environment that contains rviz, with nixpkgs 20.09:

$ nix-shell
# to get rid of error
# qt.glx: qglx_findConfig: Failed to finding matching FBConfig...
$ export QT_XCB_GL_INTEGRATION=none 
$ rosrun rviz rviz
# ...
[  INFO]: rviz version 1.13.16
[  INFO]: compiled against Qt version 5.15.2
[  INFO]: compiled against OGRE version 1.9.0 (Ghadamon)
[  INFO]: Forcing OpenGL version 0.
Segmentation fault

@mikepurvis
Copy link
Contributor

mikepurvis commented Oct 22, 2021

We're also seeing what looks like this with @lopsided98's Gazebo 11 derivation on Ubuntu 20.04.

Disregard, it turned out to be something related to automatic executable wrapping instead! The GL-related warnings were a red herring and because I was doing some of the testing on a headless machine.

@iwanders
Copy link

iwanders commented Nov 2, 2021

Just to follow up on @mikepurvis 's comment. We solved our issues by properly wrapping the Qt applications with wrapQtAppsHook. To resolve the segmentation faults when the OpenGL context is being created we are using nixGL. These segmentation faults seem to be only a problem on non-NixOS systems, where the binaries from the nix store don't have access to the libraries installed by the graphics card drivers of the operating system (in our case the libs installed by the Nvidia driver).

@exarkun
Copy link
Contributor

exarkun commented Jan 1, 2022

Just confirming that this is still broken as of 21.11.334934.8a053bc2255:

$ nix-shell -p openscad --run openscad
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
QOpenGLWidget: Failed to create context
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
QOpenGLWidget: Failed to create context
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
qt.qpa.backingstore: composeAndFlush: QOpenGLContext creation failed
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
qt.qpa.backingstore: composeAndFlush: makeCurrent() failed
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
qt.qpa.backingstore: composeAndFlush: makeCurrent() failed
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
qt.qpa.backingstore: composeAndFlush: makeCurrent() failed
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
qt.qpa.backingstore: composeAndFlush: makeCurrent() failed
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
qt.qpa.backingstore: composeAndFlush: makeCurrent() failed
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
qt.qpa.backingstore: composeAndFlush: makeCurrent() failed
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
qt.qpa.backingstore: composeAndFlush: makeCurrent() failed
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
qt.qpa.backingstore: composeAndFlush: makeCurrent() failed
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
qt.qpa.backingstore: composeAndFlush: makeCurrent() failed
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
qt.qpa.backingstore: composeAndFlush: makeCurrent() failed
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
qt.qpa.backingstore: composeAndFlush: makeCurrent() failed
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
qt.qpa.backingstore: composeAndFlush: makeCurrent() failed
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
qt.qpa.backingstore: composeAndFlush: makeCurrent() failed
QXcbIntegration: Cannot create platform offscreen surface, neither GLX nor EGL are enabled
/tmp/nix-shell-146113-0/rc: line 1: 146144 Segmentation fault      (core dumped) openscad

@exarkun
Copy link
Contributor

exarkun commented Jan 1, 2022

Since this can be reproduced with glxinfo, which is not a Qt application, it seems like this probably has nothing to do with Qt. Instead, these Qt errors are just how Qt fails when the display server doesn't support OpenGL.

The real question becomes: Why doesn't the display server support OpenGL? Answer that and fix the config and these Qt programs will probably work.

@exarkun
Copy link
Contributor

exarkun commented Jan 1, 2022

In my case, I switched from the "nvidia" driver to the "amdgpu" driver (the system has both video cards in it) and both glxinfo and openscad are working fine now.

I don't know why glx support is missing when using the "nvidia" driver. The web is littered with posts from people trying to solve that kind of issue on linux so I imagine there are a ton of possible misconfigurations that result in the situation.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 31, 2022
@Rots
Copy link

Rots commented Jul 24, 2024

also a problem on WSL

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests