A Weird Imagination

Nvidia GLX not working

The problem

I recently replaced my old Nvidia graphics card with a newer one. Upon booting up, I ran glxgears to test that 3D graphics were working properly and got an error like

X Error of failed request:  BadWindow (invalid Window parameter)
 Major opcode of failed request:  155 (NV-GLX)
 Minor opcode of failed request:  4 ()
 Resource id in failed request:  0x1200003
 Serial number of failed request:  34
 Current serial number in output stream:  34

The solution

Either delete /etc/X11/xorg.conf or edit it and remove (or comment out) the "Files" section; that is, the lines

Section "Files"

The details

Initial troubleshooting

Doing a search on the error message, I found suggestions that this was a sign the Nvidia driver installation was corrupted and a reinstall might fix it. Other posts pointed me at the Xorg logs.

Looking at the Xorg log file in /var/log/Xorg.0.log, I found messages like

(II) LoadModule: "glx"
(II) Loading /usr/lib/xorg/modules/extensions/libglx.so
(II) Module glx: vendor="X.Org Foundation"
(II) Loading extension GLX
(EE) NVIDIA(0): Failed to initialize the GLX module; please check in your X
(EE) NVIDIA(0):     log file that the GLX module has been loaded in your X
(EE) NVIDIA(0):     server, and that the module is the NVIDIA GLX module.

indicating the wrong libglx.so was being loaded.

Finding libglx.so

This leads to the question of which libglx.so should be loaded.

Using locate found

$ locate libglx.so

and wajig's whichpkg sub-command found

$ wajig whichpkg libglx.so
xserver-xorg-video-nvidia: /usr/lib/nvidia/current/libglx.so
xserver-xorg-video-nvidia: /usr/lib/nvidia/current/libglx.so.390.87
xserver-xorg-core: /usr/lib/xorg/modules/extensions/libglx.so

The desired libglx.so is the one from the Nvidia-related package (xserver-xorg-video-nvidia), not the general Xorg package (xserver-xorg-core), which suggests that /usr/lib/xorg/modules/extensions/ is not actually where Xorg should be looking for modules (at least not as the first choice).

Wait, /usr/lib/xorg/modules/linux/libglx.so isn't an installed file?

Note that /usr/lib/xorg/modules/linux/libglx.so is not actually listed by wajig whichpkg. Looking at that file reveals that it's a symbolic link:

$ ll /usr/lib/xorg/modules/linux/
total 0
lrwxrwxrwx 1 root root 38 Jan 26  2018 libglx.so -> /etc/alternatives/glx--linux-libglx.so

As the correct libglx.so to use depends on the system setup, Debian's alteratives system is used to select which one to use. A quick check in the /etc/alternatives directory shows that is indeed pointing at an Nvidia-related file as expected.

$ ll /etc/alternatives | grep glx--linux-libglx.so
lrwxrwxrwx 1 root root  25 Oct 17 20:05 glx--linux-libglx.so -> /usr/lib/nvidia/libglx.so

We also could have used readlink to skip to the final target of the chain of links:

$ readlink -f /usr/lib/xorg/modules/linux/libglx.so

Fixing ModulePath in xorg.conf

Looking in more detail at /var/log/Xorg.0.log, I noticed the line

(==) ModulePath set to "/usr/lib/xorg/modules"

To help interpret this line, looking toward the top of the log is the legend for the prefixes of the lines in this log:

Markers: (--) probed, (**) from config file, (==) default setting,
        (++) from command line, (!!) notice, (II) informational,
        (WW) warning, (EE) error, (NI) not implemented, (??) unknown.

indicating that (==) means it's the default setting. Looking at my xorg.conf, I found

Section "Files"

Given that Debian intentionally put libglx.conf in /usr/lib/xorg/modules/linux/—and that was not getting included in the ModulePath list—I figured that empty "Files" section was overridding a settings file from Debian. Indeed, after removing it, glxgears worked and Xorg.0.log contained the line

(**) ModulePath set to "/usr/lib/xorg/modules/linux,/usr/lib/xorg/modules"

indicating that path was now being correctly included in ModulePath, and the (**) indicates that it's from a config file.

Why did that work?

Looking further, the log file contains the information on the config files it uses:

(==) Using config file: "/etc/X11/xorg.conf"
(==) Using config directory: "/etc/X11/xorg.conf.d"
(==) Using system config directory "/usr/share/X11/xorg.conf.d"

In /usr/share/X11/xorg.conf.d/, the file nvidia-drm-outputclass.conf contains

Section "Files"
    ModulePath     "/usr/lib/xorg/modules/linux"
    ModulePath     "/usr/lib/xorg/modules"

which is apparently where ModulePath is supposed to be set.


Have something to add? Post a comment by sending an email to comments@aweirdimagination.net. You may use Markdown for formatting.

There are no comments yet.