Subject: Bug#919197: qtwayland-opensource-src: FTBFS on hppa - Segmentation faults in testsuite

From: John David Anglin <[email-masked]>
Date: Sun, 13 Jan 2019 13:51:04 -0500

Source: qtwayland-opensource-src
Version: 5.11.3-2
Severity: normal

Dear Maintainer,

The build fails here:

xvfb-run -a dh_auto_test -- -Ctests/auto
	make -j1 check -Ctests/auto
make[2]: Entering directory '/<<PKGBUILDDIR>>/tests/auto'
cd client/ && ( test -e Makefile || /usr/lib/qt5/bin/qmake -o Makefile /<<PKGBUILDDIR>>/tests/auto/client/client.pro 'QMAKE_CFLAGS_RELEASE=-g -O2 -fdebug-prefix-map=/<<PKGBUILDDIR>>=. -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2' 'QMAKE_CFLAGS_DEBUG=-g -O2 -fdebug-prefix-map=/<<PKGBUILDDIR>>=. -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2' 'QMAKE_CXXFLAGS_RELEASE=-g -O2 -fdebug-prefix-map=/<<PKGBUILDDIR>>=. -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2' 'QMAKE_CXXFLAGS_DEBUG=-g -O2 -fdebug-prefix-map=/<<PKGBUILDDIR>>=. -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2' QMAKE_STRIP=: PREFIX=/usr QT_BUILD_PARTS+=tests ) && make -f Makefile check
make[3]: Entering directory '/<<PKGBUILDDIR>>/tests/auto/client'
cd client/ && ( test -e Makefile || /usr/lib/qt5/bin/qmake -o Makefile /<<PKGBUILDDIR>>/tests/auto/client/client/client.pro 'QMAKE_CFLAGS_RELEASE=-g -O2 -fdebug-prefix-map=/<<PKGBUILDDIR>>=. -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2' 'QMAKE_CFLAGS_DEBUG=-g -O2 -fdebug-prefix-map=/<<PKGBUILDDIR>>=. -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2' 'QMAKE_CXXFLAGS_RELEASE=-g -O2 -fdebug-prefix-map=/<<PKGBUILDDIR>>=. -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2' 'QMAKE_CXXFLAGS_DEBUG=-g -O2 -fdebug-prefix-map=/<<PKGBUILDDIR>>=. -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2' QMAKE_STRIP=: PREFIX=/usr QT_BUILD_PARTS+=tests ) && make -f Makefile check
make[4]: Entering directory '/<<PKGBUILDDIR>>/tests/auto/client/client'
/<<PKGBUILDDIR>>/tests/auto/client/client/target_wrapper.sh  ./tst_client 
/<<PKGBUILDDIR>>/tests/auto/client/client/target_wrapper.sh: 6: /<<PKGBUILDDIR>>/tests/auto/client/client/target_wrapper.sh: TESTRUNNER: not found
/<<PKGBUILDDIR>>/tests/auto/client/client/target_wrapper.sh: 6: /<<PKGBUILDDIR>>/tests/auto/client/client/target_wrapper.sh: TESTARGS: not found
+ ./tst_client
Using Wayland-EGL
/<<PKGBUILDDIR>>/tests/auto/client/client/run-with-all-shells.sh: line 3: 28547 Segmentation fault      $@
make[4]: *** [Makefile:461: check] Error 139
make[4]: Leaving directory '/<<PKGBUILDDIR>>/tests/auto/client/client'
make[3]: *** [Makefile:528: sub-client-check] Error 2

Here is a back trace:

dave@mx3210:~/debian/qtwayland-opensource-src/qtwayland-opensource-src-5.11.3$ gdb -c ./tests/auto/client/client/core ./tests/auto/client/client/tst_client
GNU gdb (Debian 8.2-1) 8.2
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "hppa-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./tests/auto/client/client/tst_client...done.
[New LWP 26728]
[New LWP 26732]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/hppa-linux-gnu/libthread_db.so.1".
Core was generated by `./tst_client'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0xee088d44 in wayland_drm_buffer_get (resource=0x0, drm=0xc0)
    at ../../../src/egl/wayland/wayland-drm/wayland-drm.h:49
49      ../../../src/egl/wayland/wayland-drm/wayland-drm.h: No such file or directory.
[Current thread is 1 (Thread 0xf8cf7780 (LWP 26728))]
(gdb) bt
#0  0xee088d44 in wayland_drm_buffer_get (resource=0x0, drm=0xc0)
    at ../../../src/egl/wayland/wayland-drm/wayland-drm.h:49
#1  dri2_query_wayland_buffer_wl (drv=0x99760, disp=0xa3b08,
    buffer_resource=0x0, attribute=0, value=<optimized out>)
    at ../../../src/egl/drivers/dri2/egl_dri2.c:2852
#2  0xee083f34 in _eglMatchAndInitialize (dpy=<optimized out>)
    at ../../../src/egl/main/egldriver.c:69
#3  0xee083f34 in _eglMatchAndInitialize (dpy=dpy@entry=0x0)
    at ../../../src/egl/main/egldriver.c:69
#4  0xee083f98 in _eglMatchDriver (dpy=0x0, dpy@entry=0xa3b08)
    at ../../../src/egl/main/egldriver.c:90
#5  0xee07d990 in eglInitialize (dpy=0xa3b08, major=0x0, minor=0xfa1bd5dc)
    at ../../../src/egl/main/eglapi.c:591
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

(gdb) info shared
>From        To          Syms Read   Shared Object Library
0xf85fc730  0xf8a73ce4  Yes (*)     /usr/lib/hppa-linux-gnu/libQt5Gui.so.5
0xf82a47a8  0xf82db8d4  Yes (*)     /usr/lib/hppa-linux-gnu/libQt5Test.so.5
0xf7c62310  0xf7fa0854  Yes (*)     /usr/lib/hppa-linux-gnu/libQt5Core.so.5
0xf78a82ac  0xf78e9438  Yes         /usr/lib/hppa-linux-gnu/libGL.so.1
0xf73ed460  0xf74015f0  Yes         /lib/hppa-linux-gnu/libpthread.so.0
0xf723f884  0xf7245dc4  Yes         /usr/lib/hppa-linux-gnu/libwayland-client.so.0
0xf701fe30  0xf7028e08  Yes         /usr/lib/hppa-linux-gnu/libwayland-server.so.0
0xf6d7c580  0xf6e6ed64  Yes (*)     /usr/lib/hppa-linux-gnu/libstdc++.so.6
0xf6c01f60  0xf6c119a8  Yes         /lib/hppa-linux-gnu/libgcc_s.so.4
0xf680a5f0  0xf692fb0c  Yes (*)     /lib/hppa-linux-gnu/libc.so.6
0xf64ff800  0xf6529058  Yes (*)     /usr/lib/hppa-linux-gnu/libpng16.so.16
0xf612a320  0xf61fbc30  Yes (*)     /usr/lib/hppa-linux-gnu/libharfbuzz.so.0
0xf5fd1160  0xf5fe70d4  Yes (*)     /lib/hppa-linux-gnu/libz.so.1
0xf5bfed04  0xf5c40ba4  Yes (*)     /lib/hppa-linux-gnu/libm.so.6
0xf58ca340  0xf5a9e3f4  Yes (*)     /usr/lib/hppa-linux-gnu/libicui18n.so.63
0xf54484b0  0xf5545ae4  Yes (*)     /usr/lib/hppa-linux-gnu/libicuuc.so.63
0xf522fc90  0xf525c7f8  Yes (*)     /usr/lib/hppa-linux-gnu/libpcre2-16.so.0
0xf4ffdbc0  0xf500ce18  Yes (*)     /usr/lib/hppa-linux-gnu/libdouble-conversion.so.1
0xf4fe8ec8  0xf4fea6c0  Yes         /lib/hppa-linux-gnu/libdl.so.2
--Type <RET> for more, q to quit, c to continue without paging--
0xf4bf0da0  0xf4c968bc  Yes (*)     /usr/lib/hppa-linux-gnu/libglib-2.0.so.0
0xf8bf2670  0xf8c0f618  Yes         /lib/ld.so.1
0xf4aa80e0  0xf4ab892c  Yes (*)     /usr/lib/hppa-linux-gnu/libGLX.so.0
0xf4880448  0xf48bff5c  Yes (*)     /usr/lib/hppa-linux-gnu/libGLdispatch.so.0
0xf4735460  0xf473a920  Yes (*)     /usr/lib/hppa-linux-gnu/libffi.so.6
0xf43e9b7c  0xf43ee418  Yes         /lib/hppa-linux-gnu/librt.so.1
0xf42b0270  0xf433c538  Yes (*)     /usr/lib/hppa-linux-gnu/libfreetype.so.6
0xf4246f80  0xf426a328  Yes (*)     /usr/lib/hppa-linux-gnu/libgraphite2.so.3
0xf27f13f8  0xf27f186c  Yes (*)     /usr/lib/hppa-linux-gnu/libicudata.so.63
0xf23f1220  0xf241ed74  Yes (*)     /lib/hppa-linux-gnu/libpcre.so.3
0xf2085f70  0xf212c1f8  Yes (*)     /usr/lib/hppa-linux-gnu/libX11.so.6
0xf1e89d70  0xf1e97ecc  Yes (*)     /usr/lib/hppa-linux-gnu/libXext.so.6
0xf1dea9d8  0xf1dfd1b0  Yes (*)     /usr/lib/hppa-linux-gnu/libxcb.so.1
0xf1a9fb08  0xf1aa0fd0  Yes (*)     /usr/lib/hppa-linux-gnu/libXau.so.6
0xf1801e38  0xf1804170  Yes (*)     /usr/lib/hppa-linux-gnu/libXdmcp.so.6
0xf173a4c0  0xf17500ec  Yes (*)     /lib/hppa-linux-gnu/libbsd.so.0
0xf74d4f74  0xf74d7d10  Yes         /home/dave/debian/qtwayland-opensource-src/qtwayland-opensource-src-5.11.3/plugins/platforms/libqwayland-generic.so
0xf0cfe750  0xf0da5ad4  Yes         /home/dave/debian/qtwayland-opensource-src/qtwayland-opensource-src-5.11.3/lib/libQt5WaylandClient.so.5
0xf0a3ee88  0xf0a41830  Yes (*)     /usr/lib/hppa-linux-gnu/libwayland-cursor.so.0
0xf07dd9b4  0xf080c6f8  Yes (*)     /usr/lib/hppa-linux-gnu/libfontconfig.so.1
--Type <RET> for more, q to quit, c to continue without paging--
0xf03edc2c  0xf04711c8  Yes (*)     /usr/lib/hppa-linux-gnu/libQt5DBus.so.5
0xf02e51e0  0xf0306010  Yes (*)     /usr/lib/hppa-linux-gnu/libxkbcommon.so.0
0xefbd31c0  0xefc05ae0  Yes (*)     /lib/hppa-linux-gnu/libexpat.so.1
0xef843290  0xef849c18  Yes (*)     /lib/hppa-linux-gnu/libuuid.so.1
0xef7da1a0  0xef816c34  Yes (*)     /lib/hppa-linux-gnu/libdbus-1.so.3
0xef4b5f70  0xef534d74  Yes (*)     /lib/hppa-linux-gnu/libsystemd.so.0
0xef3eb124  0xef408110  Yes (*)     /lib/hppa-linux-gnu/liblzma.so.5
0xeefe9e20  0xef01a558  Yes (*)     /usr/lib/hppa-linux-gnu/liblz4.so.1
0xeebf5790  0xeec8fbc8  Yes (*)     /lib/hppa-linux-gnu/libgcrypt.so.20
0xee7f5340  0xee80ba74  Yes (*)     /lib/hppa-linux-gnu/libgpg-error.so.0
0xee45ef6c  0xee468788  Yes         /home/dave/debian/qtwayland-opensource-src/qtwayland-opensource-src-5.11.3/plugins/wayland-graphics-integration-client/libqt-plugin-wayland-egl.so
0xee429560  0xee43b14c  Yes         /usr/lib/hppa-linux-gnu/libEGL.so.1
0xee20d53c  0xee20db28  Yes         /usr/lib/hppa-linux-gnu/libwayland-egl.so.1
0xee073350  0xee0a10ac  Yes         /usr/lib/hppa-linux-gnu/libEGL_mesa.so.0
0xedc6b684  0xedc6c988  Yes (*)     /usr/lib/hppa-linux-gnu/libxcb-dri2.so.0
0xed95d480  0xed95d90c  Yes (*)     /usr/lib/hppa-linux-gnu/libX11-xcb.so.1
0xed89d388  0xed89e6bc  Yes (*)     /usr/lib/hppa-linux-gnu/libxcb-dri3.so.0
0xed4fca10  0xed4fed20  Yes (*)     /usr/lib/hppa-linux-gnu/libxcb-xfixes.so.0
0xed0f8bb8  0xed0f981c  Yes (*)     /usr/lib/hppa-linux-gnu/libxcb-present.so.0
0xeccfbfa0  0xeccfe18c  Yes (*)     /usr/lib/hppa-linux-gnu/libxcb-sync.so.1
0xecab9790  0xecabc5f8  Yes (*)     /usr/lib/hppa-linux-gnu/libxshmfence.so.1
--Type <RET> for more, q to quit, c to continue without paging--
0xec8fa754  0xec902194  Yes (*)     /usr/lib/hppa-linux-gnu/libgbm.so.1
0xec860a30  0xec86c048  Yes         /usr/lib/hppa-linux-gnu/libdrm.so.2
0xec4d5e5c  0xec4eee54  Yes         /usr/lib/hppa-linux-gnu/libglapi.so.0
(*): Shared library is missing debugging information.

Builds of previous versions were generally successful:
https://buildd.debian.org/status/logs.php?pkg=qtwayland-opensource-src&arch=hppa

Regards,
Dave Anglin

-- System Information:
Debian Release: buster/sid
  APT prefers buildd-unstable
  APT policy: (500, 'buildd-unstable'), (500, 'unstable')
Architecture: hppa (parisc64)

Kernel: Linux 4.14.90+ (SMP w/4 CPU cores)
Locale: LANG=C, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE=C (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

---

From: John David Anglin <[email-masked]>
Date: Sun, 13 Jan 2019 14:34:20 -0500

The last part of the backtrace is:
Thread 1 "tst_client" hit Breakpoint 1, eglInitialize (dpy=0xa3dc0,
    major=0xf8d02520, minor=0xf8d0251c) at
../../../src/egl/main/eglapi.c:582
582     ../../../src/egl/main/eglapi.c: No such file or directory.
(gdb) bt
#0  eglInitialize (dpy=0xa3dc0, major=0xf8d02520, minor=0xf8d0251c)
    at ../../../src/egl/main/eglapi.c:582
#1  0xee5f5d9c in eglInitialize (dpy=0xa3dc0, major=0xf8d02520,
    minor=0xf8d0251c) at g_egldispatchstubs.c:230
#2  0xee9ead68 in
QtWaylandClient::QWaylandEglClientBufferIntegration::initialize
(this=0xa3dc0, display=0xf8d02520)
    at
../../../../hardwareintegration/client/wayland-egl/qwaylandeglclientbufferintegration.cpp:110
#3  0xef70d878 in
QtWaylandClient::QWaylandIntegration::initializeClientBufferIntegration
(this=0xf8d0251c) at qwaylandintegration.cpp:357
#4  0xef70dc58 in
QtWaylandClient::QWaylandIntegration::clientBufferIntegration
    (this=0xf8d02520) at qwaylandintegration.cpp:310
#5  0x00015848 in main (argc=<optimized out>, argv=0xef7ceb44
<[email-masked]>)
    at tst_client.cpp:611

-- 
John David Anglin  [email-masked]

---

From: John David Anglin <[email-masked]>
Date: Sun, 13 Jan 2019 14:52:59 -0500

Looks to me to be a NULL pointer check issue in mesa:

static inline struct wl_drm_buffer *
wayland_drm_buffer_get(struct wl_drm *drm, struct wl_resource *resource)
{
        if (resource == NULL)
                return NULL;

        if (wl_resource_instance_of(resource, &wl_buffer_interface,
                                    &drm->buffer_interface))
                return wl_resource_get_user_data(resource);
        else
                return NULL;
}

(gdb) disass $pc-32-16,$pc+16
Dump of assembler code from 0xec46dd14 to 0xec46dd54:
   0xec46dd14 <dri2_query_wayland_buffer_wl+0>: stw rp,-14(sp)
   0xec46dd18 <dri2_query_wayland_buffer_wl+4>: ldo 80(sp),sp
   0xec46dd1c <dri2_query_wayland_buffer_wl+8>: ldw -b4(sp),ret0
   0xec46dd20 <dri2_query_wayland_buffer_wl+12>:        stw r5,-74(sp)
   0xec46dd24 <dri2_query_wayland_buffer_wl+16>:        copy r23,r5
   0xec46dd28 <dri2_query_wayland_buffer_wl+20>:        stw r4,-70(sp)
   0xec46dd2c <dri2_query_wayland_buffer_wl+24>:        stw r3,-6c(sp)
   0xec46dd30 <dri2_query_wayland_buffer_wl+28>:        stw r19,-20(sp)
   0xec46dd34 <dri2_query_wayland_buffer_wl+32>:        stw ret0,-78(sp)
   0xec46dd38 <dri2_query_wayland_buffer_wl+36>:        ldw 58(r25),ret0
   0xec46dd3c <dri2_query_wayland_buffer_wl+40>:        ldo c0(ret0),ret0
   0xec46dd40 <dri2_query_wayland_buffer_wl+44>:        movb,=
r24,r3,0xec46dd94 <dri2_query_wayland_buffer_wl+128>
=> 0xec46dd44 <dri2_query_wayland_buffer_wl+48>:        ldw 0(ret0),ret0
   0xec46dd48 <dri2_query_wayland_buffer_wl+52>:        addil L%800,r19,r1
   0xec46dd4c <dri2_query_wayland_buffer_wl+56>:        copy r19,r4
   0xec46dd50 <dri2_query_wayland_buffer_wl+60>:        ldw 200(r1),r25

The NULL pointer check has bee4n optimized away.

---

From: John David Anglin <[email-masked]>
Date: Sun, 13 Jan 2019 17:55:22 -0500

> The NULL pointer check has bee4n optimized away.
Actually, it has only been partially optimized away.  It appears the
check is still there (movb instruction)
but register r3 contains an undefined value (it is not an argument
register).  So, this seems a wrong
code bug.

Why are we building with gcc-7?

---

From: John David Anglin <[email-masked]>
Date: Mon, 14 Jan 2019 13:08:09 -0500

On 2019-01-14 12:42 p.m., Dmitry Shachnev wrote:
>> hy are we building with gcc-7?
> The latest hppa build log [1] has gcc 8.2.0.
>
> [1]: https://buildd.debian.org/status/fetch.php?pkg=qtwayland-opensource-src&arch=hppa&ver=5.11.3-2&stamp=1547325647
I was referring to mesa.  It appears to be miscompiled on hppa and
causes the FTBFS.  18.2.8-2 was built with gcc-7.  The new 18.3.0-1
on experimental in now built with gcc-8.  I did a test build of mesa
with gcc-8:
https://buildd.debian.org/status/fetch.php?pkg=mesa&arch=hppa&ver=18.2.8-2%2Bb1&stamp=1547428024&raw=0
However, it has same code issue

At this point, I think the problem is with gcc.  Either the instruction
after the movb should have been nullified, or
it shouldn't have been put in the delay slot of the movb.

I need a build outside buildd to investigation further.  I haven't
looked at the code for dri2_query_wayland_buffer_wl
(i.e., what happens when wayland_drm_buffer_get() returns NULL).

Dave

---

From: Dmitry Shachnev <[email-masked]>
Date: Mon, 14 Jan 2019 20:42:58 +0300

Hi John!

--
Dmitry Shachnev

---

From: John David Anglin <[email-masked]>
Date: Thu, 17 Jan 2019 08:13:55 -0500

>> The NULL pointer check has bee4n optimized away.
The bug is in this mesa code:

dri2_query_wayland_buffer_wl(_EGLDriver *drv, _EGLDisplay *disp,
                             struct wl_resource *buffer_resource,
                             EGLint attribute, EGLint *value)
{
   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
   struct wl_drm_buffer *buffer;
   const struct wl_drm_components_descriptor *format;

   if (!dri2_dpy)
      return EGL_FALSE;

   buffer = wayland_drm_buffer_get(dri2_dpy->wl_server_drm,
buffer_resource);
   if (!buffer)
      return EGL_FALSE;

The segmentation fault occurs because dri2_dpy is NULL.  The sequence
point in argument
evaluation requires evaluation of dri2_dpy->wl_server_drm before the
resource NULL pointer
check in wayland_drm_buffer_get.

With this fixed, qtwayland-opensource-src build is successful:
https://buildd.debian.org/status/fetch.php?pkg=qtwayland-opensource-src&arch=hppa&ver=5.11.3-2&stamp=1547696629&raw=0

Regards,
Dave Anglin

---

From: Dmitry Shachnev <[email-masked]>
Date: Sun, 20 Jan 2019 21:47:15 +0300

Hi John!

> https://buildd.debian.org/status/fetch.php?pkg=qtwayland-opensource-src&arch=hppa&ver=5.11.3-2&stamp=1547696629&raw=0

Do you understand correctly that there is nothing to fix in qtwayland then?

Have you already filed a bug against mesa?

--
Dmitry Shachnev