[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#911680: xserver-xorg-core: X server crashes when loading libglamorgl.so module (Bug #911680)



Hello Massimo Manghi,
just tried to reproduce the issue inside a debian buster amd64 qemu VM.
I never hit the crash and found you were probably running inside a VirtualBox.

Nevertheless with installed debug informations I think the crash shown
in the Xorg.log points to that location:


(gdb) bt
#0  glamor_egl_init (scrn=scrn@entry=0x5555557fc0f0, fd=<optimized out>) at ../../../../../../glamor/glamor_egl.c:992
#1  0x00007ffff5088172 in try_enable_glamor (pScrn=0x5555557fc0f0) at ../../../../../../../hw/xfree86/drivers/modesetting/driver.c:767
#2  PreInit (pScrn=0x5555557fc0f0, flags=<optimized out>) at ../../../../../../../hw/xfree86/drivers/modesetting/driver.c:994
#3  0x00005555555ef6c0 in InitOutput (pScreenInfo=pScreenInfo@entry=0x5555557c3780 <screenInfo>, argc=argc@entry=1, argv=argv@entry=0x7fffffffed08) at ../../../../../../hw/xfree86/common/xf86Init.c:522
#4  0x00005555555b26df in dix_main (argc=1, argv=0x7fffffffed08, envp=<optimized out>) at ../../../../dix/main.c:193
#5  0x00007ffff64cbb17 in __libc_start_main (main=0x55555559c640 <main>, argc=1, argv=0x7fffffffed08, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffecf8) at ../csu/libc-start.c:310
#6  0x000055555559c67a in _start ()


glamor/glamor_egl.c:
990
991         renderer = glGetString(GL_RENDERER);
992         if (strstr((const char *)renderer, "llvmpipe")) {
993             xf86DrvMsg(scrn->scrnIndex, X_INFO,
994                        "Refusing to try glamor on llvmpipe\n");


Therefore my guess would be that "glGetString(GL_RENDERER)" returns
in VirtualBox (or at least that installation) something odd.


That line originates from this patch that is applied upstream and
I assume is cherry picked [1] for that debian package version:
./debian/patches/08_dont-init-glamor-on-llvmpipe.diff

Upstream added on top of that another patch [2] to
avoid a crash that is probably exact that one we see here.

Kind regards,
Bernhard

[1] https://cgit.freedesktop.org/xorg/xserver/commit/glamor/?id=0a9415cf
[2] https://cgit.freedesktop.org/xorg/xserver/commit/glamor/glamor_egl.c?id=af151895f3cb1755a7a5631f2398a3d3b219cbef
# original:
[    23.879] (EE) Backtrace:
[    23.879] (EE) 0: /usr/lib/xorg/Xorg (OsLookupColor+0x139) [0x564f404a2de9]
[    23.880] (EE) 1: /lib/x86_64-linux-gnu/libpthread.so.0 (funlockfile+0x50) [0x7fc54b81f92f]
[    23.880] (EE) 2: /lib/x86_64-linux-gnu/libc.so.6 (explicit_bzero+0x124ed) [0x7fc54b700d8d]
[    23.880] (EE) 3: /usr/lib/xorg/modules/libglamoregl.so (glamor_egl_init+0x11d) [0x7fc5497de1fd]
[    23.880] (EE) 4: /usr/lib/xorg/modules/drivers/modesetting_drv.so (_init+0x5172) [0x7fc549a20ae2]
[    23.880] (EE) 5: /usr/lib/xorg/Xorg (InitOutput+0x9c0) [0x564f403856c0]
[    23.881] (EE) 6: /usr/lib/xorg/Xorg (InitFonts+0x1cf) [0x564f4034871f]
[    23.881] (EE) 7: /lib/x86_64-linux-gnu/libc.so.6 (__libc_start_main+0xe7) [0x7fc54b670b17]
[    23.881] (EE) 8: /usr/lib/xorg/Xorg (_start+0x2a) [0x564f4033267a]




apt update

apt install dpkg-dev devscripts gdb xserver-xorg xserver-xorg-core-dbgsym
apt build-dep xserver-xorg-core


mkdir xserver-xorg-core/orig -p
cd    xserver-xorg-core/orig
apt source xserver-xorg-core
cd ../..
 

gdb -q --args /usr/lib/xorg/Xorg

set height 0
set width 0
set pagination off
directory /home/benutzer/xserver-xorg-core/orig/xorg-server-1.20.1/glamor
b glamor_egl_init


glamor_egl_init+0x11d == glamor_egl_init+285












root@debian:~# gdb -q --args /usr/lib/xorg/Xorg
Reading symbols from /usr/lib/xorg/Xorg...Reading symbols from /usr/lib/debug/.build-id/92/cbd96948ba614f538b64667017f2b323ab4386.debug...done.
done.
(gdb) set height 0
(gdb) set width 0
(gdb) set pagination off
(gdb) directory /home/benutzer/xserver-xorg-core/orig/xorg-server-1.20.1/glamor
Source directories searched: /home/benutzer/xserver-xorg-core/orig/xorg-server-1.20.1/glamor:$cdir:$cwd

(gdb) b glamor_egl_init
Function "glamor_egl_init" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (glamor_egl_init) pending.

(gdb) run
Starting program: /usr/lib/xorg/Xorg 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

X.Org X Server 1.20.1
X Protocol Version 11, Revision 0
Build Operating System: Linux 4.9.0-8-amd64 x86_64 Debian
Current Operating System: Linux debian 4.18.0-2-amd64 #1 SMP Debian 4.18.10-2 (2018-10-07) x86_64
Kernel command line: BOOT_IMAGE=/boot/vmlinuz-4.18.0-2-amd64 root=UUID=3de4a194-fb38-4aa0-a7f8-5faf23bafde2 ro vga=788 quiet
Build Date: 10 October 2018  04:23:15PM
xorg-server 2:1.20.1-5 (https://www.debian.org/support) 
Current version of pixman: 0.34.0
        Before reporting problems, check http://wiki.x.org
        to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
        (++) from command line, (!!) notice, (II) informational,
        (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.0.log", Time: Tue Oct 23 20:58:31 2018
(==) Using system config directory "/usr/share/X11/xorg.conf.d"
[tcsetpgrp failed in terminal_inferior: Die Operation ist nicht erlaubt]

Breakpoint 1, glamor_egl_init (scrn=scrn@entry=0x5555557fc0f0, fd=14) at ../../../../../../glamor/glamor_egl.c:897
warning: Source file is more recent than executable.
897         glamor_egl = calloc(sizeof(*glamor_egl), 1);

(gdb) disassemble glamor_egl_init
...
   0x00007ffff4e4a1e9 <+265>:   callq  *(%rax)
   0x00007ffff4e4a1eb <+267>:   lea    0x1e168(%rip),%rsi        # 0x7ffff4e6835a
   0x00007ffff4e4a1f2 <+274>:   mov    %rax,%rdi
   0x00007ffff4e4a1f5 <+277>:   mov    %rax,%rbp
   0x00007ffff4e4a1f8 <+280>:   callq  0x7ffff4e484b0 <strstr@plt>
   0x00007ffff4e4a1fd <+285>:   test   %rax,%rax                                           <-- == glamor_egl_init+0x11d
   0x00007ffff4e4a200 <+288>:   je     0x7ffff4e4a308 <glamor_egl_init+552>
   0x00007ffff4e4a206 <+294>:   mov    0x18(%r12),%edi
   0x00007ffff4e4a20b <+299>:   lea    0x1dfc6(%rip),%rdx        # 0x7ffff4e681d8
...
End of assembler dump.

(gdb) b *0x00007ffff4e4a1f8
Breakpoint 2 at 0x7ffff4e4a1f8: file ../../../../../../glamor/glamor_egl.c, line 992.
(gdb) cont
Continuing.
pci id for fd 14: 1234:1111, driver (null)
[New Thread 0x7fffef8e0700 (LWP 23274)]
[New Thread 0x7fffef0df700 (LWP 23275)]
[New Thread 0x7fffee8de700 (LWP 23276)]
[New Thread 0x7fffee0dd700 (LWP 23277)]
[New Thread 0x7fffed8dc700 (LWP 23278)]
[New Thread 0x7fffed0db700 (LWP 23279)]
[New Thread 0x7fffec8da700 (LWP 23280)]
[New Thread 0x7fffd7fff700 (LWP 23281)]

Thread 1 "Xorg" hit Breakpoint 2, glamor_egl_init (scrn=scrn@entry=0x5555557fc0f0, fd=<optimized out>) at ../../../../../../glamor/glamor_egl.c:992
992         if (strstr((const char *)renderer, "llvmpipe")) {

# Needs a dpkg-buildpackage to hit the right line ...

(gdb) bt
#0  glamor_egl_init (scrn=scrn@entry=0x5555557fc0f0, fd=<optimized out>) at ../../../../../../glamor/glamor_egl.c:992
#1  0x00007ffff5088172 in try_enable_glamor (pScrn=0x5555557fc0f0) at ../../../../../../../hw/xfree86/drivers/modesetting/driver.c:767
#2  PreInit (pScrn=0x5555557fc0f0, flags=<optimized out>) at ../../../../../../../hw/xfree86/drivers/modesetting/driver.c:994
#3  0x00005555555ef6c0 in InitOutput (pScreenInfo=pScreenInfo@entry=0x5555557c3780 <screenInfo>, argc=argc@entry=1, argv=argv@entry=0x7fffffffed08) at ../../../../../../hw/xfree86/common/xf86Init.c:522
#4  0x00005555555b26df in dix_main (argc=1, argv=0x7fffffffed08, envp=<optimized out>) at ../../../../dix/main.c:193
#5  0x00007ffff64cbb17 in __libc_start_main (main=0x55555559c640 <main>, argc=1, argv=0x7fffffffed08, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffecf8) at ../csu/libc-start.c:310
#6  0x000055555559c67a in _start ()

(gdb) display/i $pc
1: x/i $pc
=> 0x7ffff4e4a1f8 <glamor_egl_init+280>:        callq  0x7ffff4e484b0 <strstr@plt>

(gdb) print renderer
$1 = (const GLubyte *) 0x7ffff4a1f580 "llvmpipe (LLVM 6.0, 128 bits)"



(gdb) list 891,1000
891     Bool
892     glamor_egl_init(ScrnInfoPtr scrn, int fd)
893     {
894         struct glamor_egl_screen_private *glamor_egl;
895         const GLubyte *renderer;
896
897         glamor_egl = calloc(sizeof(*glamor_egl), 1);
898         if (glamor_egl == NULL)
899             return FALSE;
900         if (xf86GlamorEGLPrivateIndex == -1)
901             xf86GlamorEGLPrivateIndex = xf86AllocateScrnInfoPrivateIndex();
902
903         scrn->privates[xf86GlamorEGLPrivateIndex].ptr = glamor_egl;
904         glamor_egl->fd = fd;
905         glamor_egl->gbm = gbm_create_device(glamor_egl->fd);
906         if (glamor_egl->gbm == NULL) {
907             ErrorF("couldn't get display device\n");
908             goto error;
909         }
910
911         glamor_egl->display = glamor_egl_get_display(EGL_PLATFORM_GBM_MESA,
912                                                      glamor_egl->gbm);
913         if (!glamor_egl->display) {
914             xf86DrvMsg(scrn->scrnIndex, X_ERROR, "eglGetDisplay() failed\n");
915             goto error;
916         }
917
918         if (!eglInitialize(glamor_egl->display, NULL, NULL)) {
919             xf86DrvMsg(scrn->scrnIndex, X_ERROR, "eglInitialize() failed\n");
920             glamor_egl->display = EGL_NO_DISPLAY;
921             goto error;
922         }
923
924     #define GLAMOR_CHECK_EGL_EXTENSION(EXT)  \
925             if (!epoxy_has_egl_extension(glamor_egl->display, "EGL_" #EXT)) {  \
926                     ErrorF("EGL_" #EXT " required.\n");  \
927                     goto error;  \
928             }
929
930     #define GLAMOR_CHECK_EGL_EXTENSIONS(EXT1, EXT2)  \
931             if (!epoxy_has_egl_extension(glamor_egl->display, "EGL_" #EXT1) &&  \
932                 !epoxy_has_egl_extension(glamor_egl->display, "EGL_" #EXT2)) {  \
933                     ErrorF("EGL_" #EXT1 " or EGL_" #EXT2 " required.\n");  \
934                     goto error;  \
935             }
936
937         GLAMOR_CHECK_EGL_EXTENSION(KHR_surfaceless_context);
938
939         if (eglBindAPI(EGL_OPENGL_API)) {
940             static const EGLint config_attribs_core[] = {
941                 EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR,
942                 EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR,
943                 EGL_CONTEXT_MAJOR_VERSION_KHR,
944                 GLAMOR_GL_CORE_VER_MAJOR,
945                 EGL_CONTEXT_MINOR_VERSION_KHR,
946                 GLAMOR_GL_CORE_VER_MINOR,
947                 EGL_NONE
948             };
949             static const EGLint config_attribs[] = {
950                 EGL_NONE
951             };
952
953             glamor_egl->context = eglCreateContext(glamor_egl->display,
954                                                    NULL, EGL_NO_CONTEXT,
955                                                    config_attribs_core);
956
957             if (glamor_egl->context == EGL_NO_CONTEXT)
958                 glamor_egl->context = eglCreateContext(glamor_egl->display,
959                                                        NULL, EGL_NO_CONTEXT,
960                                                        config_attribs);
961         }
962
963         if (glamor_egl->context == EGL_NO_CONTEXT) {
964             static const EGLint config_attribs[] = {
965                 EGL_CONTEXT_CLIENT_VERSION, 2,
966                 EGL_NONE
967             };
968             if (!eglBindAPI(EGL_OPENGL_ES_API)) {
969                 xf86DrvMsg(scrn->scrnIndex, X_ERROR,
970                            "glamor: Failed to bind either GL or GLES APIs.\n");
971                 goto error;
972             }
973
974             glamor_egl->context = eglCreateContext(glamor_egl->display,
975                                                    NULL, EGL_NO_CONTEXT,
976                                                    config_attribs);
977         }
978         if (glamor_egl->context == EGL_NO_CONTEXT) {
979             xf86DrvMsg(scrn->scrnIndex, X_ERROR,
980                        "glamor: Failed to create GL or GLES2 contexts\n");
981             goto error;
982         }
983
984         if (!eglMakeCurrent(glamor_egl->display,
985                             EGL_NO_SURFACE, EGL_NO_SURFACE, glamor_egl->context)) {
986             xf86DrvMsg(scrn->scrnIndex, X_ERROR,
987                        "Failed to make EGL context current\n");
988             goto error;
989         }
990
991         renderer = glGetString(GL_RENDERER);
992         if (strstr((const char *)renderer, "llvmpipe")) {
993             xf86DrvMsg(scrn->scrnIndex, X_INFO,
994                        "Refusing to try glamor on llvmpipe\n");
995             goto error;
996         }
997
998         /*
999          * Force the next glamor_make_current call to set the right context
1000         * (in case of multiple GPUs using glamor)






benutzer@debian:~/xserver-xorg-core/orig/xorg-server-1.20.1$ cat ./debian/patches/08_dont-init-glamor-on-llvmpipe.diff
commit 0a9415cf793babed1f28c61f8047d51de04f1528
Author: Adam Jackson <ajax@redhat.com>
Date:   Fri Sep 14 11:33:43 2018 -0400

    glamor_egl: Don't initialize on llvmpipe
    
    Mesa started supporting GL_OES_EGL_image on llvmpipe in 17.3, after this
    commit:
    
        commit bbdeddd5fd0b797e1e281f058338b3da4d98029d
        Author: Gurchetan Singh <gurchetansingh@chromium.org>
        Date:   Tue Aug 1 14:49:33 2017 -0700
    
            st/dri: add drisw image extension
    
    That's pretty cool, but it means glamor now thinks it can initialize on
    llvmpipe. This is almost certainly not what anyone wants, as glamor on
    llvmpipe is pretty much uniformly slower than fb.
    
    This fixes both Xorg and Xwayland to refuse glamor in such a setup.
    Xephyr is left alone, both because glamor is not the default there and
    because Xephyr+glamor+llvmpipe is one of the easier ways to get xts to
    exercise glamor.
    
    The (very small) downside of this change is that you lose DRI3 support.
    This wouldn't have helped you very much (since an lp glamor blit is
    slower than a pixman blit), but it would eliminate the PutImage overhead
    for llvmpipe's glXSwapBuffers. A future change should add DRI3 support
    for the fb-only case.
    
    Reviewed-by: Eric Anholt <eric@anholt.net>
    Signed-off-by: Adam Jackson <ajax@redhat.com>

diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index df278b1a1..9b930d603 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -898,6 +898,7 @@ Bool
 glamor_egl_init(ScrnInfoPtr scrn, int fd)
 {
     struct glamor_egl_screen_private *glamor_egl;
+    const GLubyte *renderer;
 
     glamor_egl = calloc(sizeof(*glamor_egl), 1);
     if (glamor_egl == NULL)
@@ -992,6 +993,14 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
                    "Failed to make EGL context current\n");
         goto error;
     }
+
+    renderer = glGetString(GL_RENDERER);
+    if (strstr((const char *)renderer, "llvmpipe")) {
+        xf86DrvMsg(scrn->scrnIndex, X_INFO,
+                   "Refusing to try glamor on llvmpipe\n");
+        goto error;
+    }
+
     /*
      * Force the next glamor_make_current call to set the right context
      * (in case of multiple GPUs using glamor)
@@ -1005,7 +1014,7 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
     }
 
     xf86DrvMsg(scrn->scrnIndex, X_INFO, "glamor X acceleration enabled on %s\n",
-               glGetString(GL_RENDERER));
+               renderer);
 
 #ifdef GBM_BO_WITH_MODIFIERS
     if (epoxy_has_egl_extension(glamor_egl->display,
diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c
index 06fcf5239..25a354bf7 100644
--- a/hw/xwayland/xwayland-glamor-gbm.c
+++ b/hw/xwayland/xwayland-glamor-gbm.c
@@ -843,6 +843,11 @@ xwl_glamor_gbm_init_egl(struct xwl_screen *xwl_screen)
         goto error;
     }
 
+    if (strstr((const char *)glGetString(GL_RENDERER), "llvmpipe")) {
+        ErrorF("Refusing to try glamor on llvmpipe\n");
+        goto error;
+    }
+
     if (!epoxy_has_gl_extension("GL_OES_EGL_image")) {
         ErrorF("GL_OES_EGL_image not available\n");
         goto error;















[1] https://cgit.freedesktop.org/xorg/xserver/commit/glamor/?id=0a9415cf
[2] https://cgit.freedesktop.org/xorg/xserver/commit/glamor/glamor_egl.c?id=af151895f3cb1755a7a5631f2398a3d3b219cbef

Reply to: