Memory corruption: libnvidia-egl-gbm is writing/reading below the address of gbm_surface

Memory corruption: libnvidia-egl-gbm is writing/reading below the address of gbm_surface:

==2451== Invalid write of size 8
==2451==    at 0x108E6BED: ??? (in /usr/lib/x86_64-linux-gnu/libnvidia-egl-gbm.so.1.1.0)
==2451==    by 0xE30704A: ??? (in /usr/lib/x86_64-linux-gnu/libEGL_nvidia.so.495.44)
==2451==    by 0xE3070DC: ??? (in /usr/lib/x86_64-linux-gnu/libEGL_nvidia.so.495.44)
==2451==    by 0xE2A83EF: ??? (in /usr/lib/x86_64-linux-gnu/libEGL_nvidia.so.495.44)
            <eglCreateWindowSurface>
==2451==    by 0x5C0864E: meta_egl_create_window_surface (meta-egl.c:413)
==2451==    by 0x5C919EF: create_surfaces_gbm (meta-onscreen-native.c:1652)
==2451==    by 0x5C91F05: meta_onscreen_native_allocate (meta-onscreen-native.c:1808)
==2451==    by 0x63EF1B6: cogl_framebuffer_allocate (cogl-framebuffer.c:954)
==2451==    by 0x5C99052: meta_renderer_native_create_view (meta-renderer-native.c:1175)
==2451==    by 0x5B4695D: meta_renderer_create_view (meta-renderer.c:102)
==2451==    by 0x5B469CD: create_crtc_view (meta-renderer.c:133)
==2451==    by 0x5B2C62E: foreach_crtc (meta-logical-monitor.c:247)
==2451==  Address 0x278ea858 is 8 bytes before a block of size 48 alloc'd
==2451==    at 0x4848A23: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==2451==    by 0x801BCC0: gbm_dri_surface_create (gbm_dri.c:1316)
==2451==    by 0x801FC82: gbm_surface_create (gbm.c:624)
==2451==    by 0x5C9197B: create_surfaces_gbm (meta-onscreen-native.c:1636)
==2451==    by 0x5C91F05: meta_onscreen_native_allocate (meta-onscreen-native.c:1808)
==2451==    by 0x63EF1B6: cogl_framebuffer_allocate (cogl-framebuffer.c:954)
==2451==    by 0x5C99052: meta_renderer_native_create_view (meta-renderer-native.c:1175)
==2451==    by 0x5B4695D: meta_renderer_create_view (meta-renderer.c:102)
==2451==    by 0x5B469CD: create_crtc_view (meta-renderer.c:133)
==2451==    by 0x5B2C62E: foreach_crtc (meta-logical-monitor.c:247)
==2451==    by 0x5B30717: meta_monitor_mode_foreach_crtc (meta-monitor.c:1955)
==2451==    by 0x5B2C6C8: meta_logical_monitor_foreach_crtc (meta-logical-monitor.c:274)

and similarly later:

==2451== Invalid read of size 8
==2451==    at 0x108E68A7: ??? (in /usr/lib/x86_64-linux-gnu/libnvidia-egl-gbm.so.1.1.0)
            <gbm_surface_lock_front_buffer>
==2451==    by 0x5C6F28E: lock_front_buffer (meta-drm-buffer-gbm.c:179)
==2451==    by 0x5C6F368: meta_drm_buffer_gbm_new_lock_front (meta-drm-buffer-gbm.c:206)
  • mesa = 21.2.2
  • nvidia-egl-wayland = 1.1.9
  • nvidia = 495.44
  • mutter = main branch

And figured out in mutter/gnome-shell main fails to start on Nvidia-495.44 (#1998) · Issues · GNOME / mutter · GitLab

The problem was somewhat obvious from the first above stack that nvidia-drm_gbm.so is never found and loaded. I suspect some extra error checking is in order because this isn’t an ideal way to discover a simple installation path bug.