Need help debuging ubuntu 20.04 opengl install

When running glxinfo I get the error:
X Error of failed request: GLXBadContext
Using the source code from mesa-demos-8.4.0 I find the error occurs because of a call to glxCreateNewContext(). The system has a problem, but it is not clear to me how to fix it.

I get the following outputs from various other commands:

$ inxi -Gx
Graphics:  Device-1: Advanced Micro Devices [AMD/ATI] Ellesmere [Radeon RX 470/480/570/570X/580/580X/590] 
           vendor: XFX Pine driver: amdgpu v: 5.9.10.20.50 bus ID: 01:00.0 
           Display: wayland server: X.Org 1.20.9 driver: amdgpu resolution: 2560x1440~60Hz 
           OpenGL: renderer: N/A v: N/A direct render: N/A 

$ dpkg --list | grep -i "glx"
ii  libgl1-amdgpu-mesa-glx:amd64                                1:20.2.4-1234664                                                                amd64        free implementation of the OpenGL API -- GLX runtime
ii  libgl1-amdgpu-mesa-glx:i386                                 1:20.2.4-1234664                                                                i386         free implementation of the OpenGL API -- GLX runtime
ii  libglx-dev:amd64                                            1.3.2-1~ubuntu0.20.04.1                                                         amd64        Vendor neutral GL dispatch library -- GLX development files
ii  libglx-mesa0:amd64                                          20.2.6-0ubuntu0.20.04.1                                                         amd64        free implementation of the OpenGL API -- GLX vendor library
ii  libglx-mesa0:i386                                           20.2.6-0ubuntu0.20.04.1                                                         i386         free implementation of the OpenGL API -- GLX vendor library
ii  libglx0:amd64                                               1.3.2-1~ubuntu0.20.04.1                                                         amd64        Vendor neutral GL dispatch library -- GLX support
ii  libglx0:i386                                                1.3.2-1~ubuntu0.20.04.1                                                         i386         Vendor neutral GL dispatch library -- GLX support
ii  libxcb-glx0:amd64                                           1.14-2                                                                          amd64        X C Binding, glx extension
ii  libxcb-glx0:i386                                            1.14-2                                                                          i386         X C Binding, glx extension

I think a bit needs to be flipped so the opengl renderer is connected to the drivers, but I have no clue how to do that. Everything looks like it should work, but obviously something is not happy. I would appreciate any ideas on how to debug this and get the system up and running so I can real work done.

1 Like

Here are a few more clues:

$ xrandr
Screen 0: minimum 16 x 16, current 2560 x 1440, maximum 32767 x 32767
XWAYLAND2 connected 2560x1440+0+0 (normal left inverted right x axis y axis) 550mm x 310mm
   2560x1440     59.91*+
$ xrandr --listproviders
Providers: number : 0

and from xdpyinfo

$ xdpyinfo | grep -A50 extensions
number of extensions:    25
    BIG-REQUESTS
    Composite
    DAMAGE
    DOUBLE-BUFFER
    DRI3
    GLX
    Generic Event Extension
    MIT-SCREEN-SAVER
    MIT-SHM
    Present
    RANDR
    RECORD
    RENDER
    SECURITY
    SHAPE
    SYNC
    X-Resource
    XC-MISC
    XFIXES
    XFree86-VidModeExtension
    XINERAMA
    XInputExtension
    XKEYBOARD
    XTEST
    XVideo

There is no Xorg.0.log anywhere. Still digging…

  • Does glxgears generate the same error?
  • Might try ldd glxgears just for information.
  • Also strace glxgears might give some clues as to which runtime-determined graphics driver DLLs are being loaded (e.g. by glvnd).
  • Try disabling Wayland and enabling the Xorg display server (prob explains why you have no Xorg.0.log)

Yes, glxgears gives the same error.

$ ldd /usr/bin/glxgears
	linux-vdso.so.1 (0x00007ffcea351000)
	libGL.so.1 => /opt/amdgpu/lib/x86_64-linux-gnu/libGL.so.1 (0x00007fc6dec32000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fc6deae3000)
	libX11.so.6 => /lib/x86_64-linux-gnu/libX11.so.6 (0x00007fc6de9a6000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fc6de7b4000)
	libglapi.so.0 => /opt/amdgpu/lib/x86_64-linux-gnu/libglapi.so.0 (0x00007fc6de77a000)
	libdrm.so.2 => /opt/amdgpu/lib/x86_64-linux-gnu/libdrm.so.2 (0x00007fc6de763000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fc6de75b000)
	libxcb-glx.so.0 => /lib/x86_64-linux-gnu/libxcb-glx.so.0 (0x00007fc6de73e000)
	libxcb.so.1 => /lib/x86_64-linux-gnu/libxcb.so.1 (0x00007fc6de714000)
	libX11-xcb.so.1 => /lib/x86_64-linux-gnu/libX11-xcb.so.1 (0x00007fc6de70f000)
	libxcb-dri2.so.0 => /lib/x86_64-linux-gnu/libxcb-dri2.so.0 (0x00007fc6de708000)
	libXext.so.6 => /lib/x86_64-linux-gnu/libXext.so.6 (0x00007fc6de6f3000)
	libXfixes.so.3 => /lib/x86_64-linux-gnu/libXfixes.so.3 (0x00007fc6de6e9000)
	libXdamage.so.1 => /lib/x86_64-linux-gnu/libXdamage.so.1 (0x00007fc6de6e4000)
	libXxf86vm.so.1 => /lib/x86_64-linux-gnu/libXxf86vm.so.1 (0x00007fc6de6dd000)
	libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007fc6de6af000)
	libxcb-dri3.so.0 => /lib/x86_64-linux-gnu/libxcb-dri3.so.0 (0x00007fc6de6a9000)
	libxcb-present.so.0 => /lib/x86_64-linux-gnu/libxcb-present.so.0 (0x00007fc6de6a4000)
	libxcb-sync.so.1 => /lib/x86_64-linux-gnu/libxcb-sync.so.1 (0x00007fc6de698000)
	libxshmfence.so.1 => /lib/x86_64-linux-gnu/libxshmfence.so.1 (0x00007fc6de496000)
	libxcb-xfixes.so.0 => /lib/x86_64-linux-gnu/libxcb-xfixes.so.0 (0x00007fc6de48c000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fc6de469000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fc6decdb000)
	libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007fc6de43e000)
	libXau.so.6 => /lib/x86_64-linux-gnu/libXau.so.6 (0x00007fc6de436000)
	libXdmcp.so.6 => /lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007fc6de42e000)
	libpcre2-8.so.0 => /lib/x86_64-linux-gnu/libpcre2-8.so.0 (0x00007fc6de39e000)
	libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007fc6de384000)

strace dumps a ton of crap, and it looks like it is mostly successful in finding the files it is looking for. The last file it finds just fine, then dies (I assume at the glxCreateNewContext point):

[....]
access("/usr/share/X11/locale/C/XLC_LOCALE", R_OK) = 0
openat(AT_FDCWD, "/usr/share/X11/locale/C/XLC_LOCALE", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0644, st_size=693, ...}) = 0
read(4, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"..., 4096) = 693
read(4, "", 4096)                       = 0
close(4)                                = 0
brk(0x55b5e27f6000)                     = 0x55b5e27f6000
write(2, "X Error of failed request:  GLXB"..., 44X Error of failed request:  GLXBadContext
  ) = 44
write(2, "Major opcode of failed request: "..., 36Major opcode of failed request:  151) = 36
write(2, " (GLX)\n", 7 (GLX)
)                 = 7
[....]

I don’t know how to disable Wayland, but I will hit up google and see if I can figure that out.
Thanks!

That was interesting. I disabled Wayland, and did sudo service gdm3 restart and the system logged me out and put up a login screen. As soon as I started typing, the screen went to a terminal with a blinking underline cursor, and took no further input. I ssh-ed in from another computer, put Wayland back, and the graphics are fine.

I did find a hint in /var/log/syslog to look in a different place (/var/lib/gdm3…) where there are Xorg.j.log files. The last one was j == 3 which had this in it:

[ 73980.733] (II) AMDGPU: Driver for AMD Radeon:
	All GPUs supported by the amdgpu kernel driver
[ 73980.733] (II) modesetting: Driver for Modesetting Kernel Drivers: kms
[ 73980.733] (II) FBDEV: driver for framebuffer: fbdev
[ 73980.733] (II) VESA: driver for VESA chipsets: vesa
[ 73980.733] (WW) xf86OpenConsole: VT_ACTIVATE failed: Operation not permitted
[ 73980.733] (EE) 
Fatal server error:
[ 73980.733] (EE) xf86OpenConsole: Switching VT failed
[ 73980.733] (EE) 
[ 73980.733] (EE) 
Please consult the The X.Org Foundation support 
	 at http://wiki.x.org
 for help. 
[ 73980.733] (EE) Please also check the log file at "/var/lib/gdm3/.local/share/xorg/Xorg.3.log" for additional information.
[ 73980.733] (EE) 
[ 73980.733] (WW) xf86CloseConsole: KDSETMODE failed: Operation not permitted
[ 73980.733] (WW) xf86CloseConsole: VT_SETMODE failed: Operation not permitted
[ 73980.733] (WW) xf86CloseConsole: VT_ACTIVATE failed: Operation not permitted
[ 73980.783] (EE) Server terminated with error (1). Closing log file.

There are lots of warnings that there are no sections in xorg.conf, but a default should have worked.

It would be nice if the error is common, but it looks like Xorg does not get as far as Wayland. I don’t really care so long as I can do accelerated 3D graphics, but I guess the question is what set of errors is easier to deal with and correct?

As usual, a very deep rabbit hole.

You might look up the Ubuntu forums for clues. I bet someone there has hit this problem before.

You are not kidding a lot of people have the problem. There do not seem to be any solutions. Partly because each case is different.

So let me start with a shovel and try to open up the rabbit hole. How do the drivers and opengl API actually connect? In my case, the output from inxi says the drivers and hardware know each other, but the opengl is not connected. That’s consistent with the call to glxCreateNewContext() failing - there is a hook from the API to the driver missing. How is that connection established?

Holy Shit!! I found the bit!!

export LIBGL_ALWAYS_INDIRECT=0

glxinfo then just works, and glxgears just works. In addition I get

$ inxi -Gx
Graphics:  Device-1: Advanced Micro Devices [AMD/ATI] Ellesmere [Radeon RX 470/480/570/570X/580/580X/590] vendor: XFX Pine 
           driver: amdgpu v: 5.9.10.20.50 bus ID: 01:00.0 
           Display: wayland server: X.Org 1.20.9 driver: amdgpu resolution: 2560x1440~60Hz 
           OpenGL: renderer: Radeon RX 580 Series (POLARIS10 DRM 3.40.0 5.8.0-49-generic LLVM 11.0.1) v: 4.6 Mesa 20.2.4 
           direct render: Yes 

That only took me 3 days :slight_smile:
Thanks for giving clues - Sometimes brownian motion actually gets the job done.

Was LIBGL_ALWAYS_INDIRECT already set? (to 1 or true)

That’s weird. Wonder what did that.

I have a lot of questions, but too much other stuff to do to figure them out. My fundamental problem is that everything is interesting, and it would be fun to figure out the details here. I have to use .bashrc to force the bit clear on login - so yeah, where is it set to begin with? The boot and login processes are long and complicated and it could be in any of a dozen places. At any rate, all is happy when things actually work and I can do 3d graphics at a reasonable speed using all this amazingly powerful hardware. Thanks for giving clues and asking questions, very much appreciated.

Same here. :slight_smile: Got to prioritize.

Possibly in one of:

  • /etc/profile
  • /etc/bash.profile (Ubuntu)
  • /etc/bashrc (Redhat)
  • ~/.bash_profile

Good. That’s the main thing.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.