test_bitcoin-qt error: “Unable to init server: Could not connect: Connection refused” #23160

issue ryanofsky openend this issue on October 2, 2021
  1. ryanofsky commented at 1:22 am on October 2, 2021: member

    tl;dr: Running unset QT_QPA_PLATFORMTHEME fixes this.


    I recently started seeing the following error on my system running test_bitcoin-qt:

    0$ src/qt/test/test_bitcoin-qt 
    1Unable to init server: Could not connect: Connection refused
    2
    3(test_bitcoin-qt:173399): Gtk-WARNING **: 21:03:26.220: cannot open display: 
    

    strace shows the failing connect:

    0connect(8, {sa_family=AF_UNIX, sun_path=@"/run/user/1000/broadway1.socket"}, 34) = -1 ECONNREFUSED (Connection refused)
    

    gdb stack trace shows:

     0$ gdb -ex 'catch syscall connect' -ex run --args  src/qt/test/test_bitcoin-qt 
     1...
     2Thread 1 "b-test" hit Catchpoint 1 (call to syscall connect), 0x00007ffff6757147 in connect ()
     3   from /nix/store/9bh3986bpragfjmr32gay8p95k91q4gy-glibc-2.33-47/lib/libpthread.so.0
     4(gdb) bt
     5[#0](/bitcoin-bitcoin/0/)  0x00007ffff6757147 in connect () from /nix/store/9bh3986bpragfjmr32gay8p95k91q4gy-glibc-2.33-47/lib/libpthread.so.0
     6[#1](/bitcoin-bitcoin/1/)  0x00007fffe272b7c6 in wl_display_connect () from /nix/store/wzii64jykrwq9y4x7f7hnplyk9asd1an-wayland-1.19.0/lib/libwayland-client.so.0
     7[#2](/bitcoin-bitcoin/2/)  0x00007fffe2f75a8a in _gdk_wayland_display_open () from /nix/store/5avyrz7fbxdypa272h5pciijdxh83x4h-gtk+3-3.24.30/lib/libgdk-3.so.0
     8[#3](/bitcoin-bitcoin/3/)  0x00007fffe2f42847 in gdk_display_manager_open_display () from /nix/store/5avyrz7fbxdypa272h5pciijdxh83x4h-gtk+3-3.24.30/lib/libgdk-3.so.0
     9[#4](/bitcoin-bitcoin/4/)  0x00007fffe3207ea3 in gtk_init_check () from /nix/store/5avyrz7fbxdypa272h5pciijdxh83x4h-gtk+3-3.24.30/lib/libgtk-3.so.0
    10[#5](/bitcoin-bitcoin/5/)  0x00007fffe3207ed9 in gtk_init () from /nix/store/5avyrz7fbxdypa272h5pciijdxh83x4h-gtk+3-3.24.30/lib/libgtk-3.so.0
    11[#6](/bitcoin-bitcoin/6/)  0x00007fffe3818fa6 in GnomeSettingsPrivate::GnomeSettingsPrivate(QObject*) () from /nix/store/m6np8hp9s198ilw8fbm3wbvdrp44jw10-qgnomeplatform-0.8.0/lib/libqgnomeplatform.so
    12[#7](/bitcoin-bitcoin/7/)  0x00007fffe381a00e in GnomeSettings::palette() () from /nix/store/m6np8hp9s198ilw8fbm3wbvdrp44jw10-qgnomeplatform-0.8.0/lib/libqgnomeplatform.so
    13[#8](/bitcoin-bitcoin/8/)  0x00007ffff74ffede in QApplicationPrivate::basePalette() const () from /nix/store/w4ajfg01a0ip7r5nl21c5gs2n9mgkyzi-qtbase-5.15.2/lib/libQt5Widgets.so.5
    14[#9](/bitcoin-bitcoin/9/)  0x00007ffff6e41cd0 in QGuiApplicationPrivate::setPalette(QPalette const&) () from /nix/store/w4ajfg01a0ip7r5nl21c5gs2n9mgkyzi-qtbase-5.15.2/lib/libQt5Gui.so.5
    15[#10](/bitcoin-bitcoin/10/) 0x00007ffff6e46663 in QGuiApplicationPrivate::updatePalette() () from /nix/store/w4ajfg01a0ip7r5nl21c5gs2n9mgkyzi-qtbase-5.15.2/lib/libQt5Gui.so.5
    16[#11](/bitcoin-bitcoin/11/) 0x00007ffff6e483d1 in QGuiApplicationPrivate::init() () from /nix/store/w4ajfg01a0ip7r5nl21c5gs2n9mgkyzi-qtbase-5.15.2/lib/libQt5Gui.so.5
    17[#12](/bitcoin-bitcoin/12/) 0x00007ffff7506c09 in QApplicationPrivate::init() () from /nix/store/w4ajfg01a0ip7r5nl21c5gs2n9mgkyzi-qtbase-5.15.2/lib/libQt5Widgets.so.5
    18[#13](/bitcoin-bitcoin/13/) 0x00005555556b291d in BitcoinApplication::BitcoinApplication (this=0x7fffffff0ac0) at qt/bitcoin.cpp:218
    19[#14](/bitcoin-bitcoin/14/) 0x0000555555672a61 in main (argc=<optimized out>, argv=0x7fffffff0d10) at qt/test/test_main.cpp:80
    

    Qt debug output shows:

    0$ QT_DEBUG_PLUGINS=1 src/qt/test/test_bitcoin-qt
    1...
    2Got keys from plugin meta data ("xdgdesktopportal", "flatpak", "snap")
    3QFactoryLoader::QFactoryLoader() checking directory path "/run/mount/chainssd-2/home-work/bitcoin/src/qt/test/platformthemes" ...
    4loaded library "/nix/store/m6np8hp9s198ilw8fbm3wbvdrp44jw10-qgnomeplatform-0.8.0/lib/qt-5.15.2/plugins/platformthemes/libqgnomeplatformtheme.so"
    5Unable to init server: Could not connect: Connection refused
    6
    7(test_bitcoin-qt:173628): Gtk-WARNING **: 21:08:27.982: cannot open display: 
    

    So the failure happens loading gnome platform plugin, and apparently on my system this is enabled by an environment variable:

    0$ env | grep QPA
    1QT_QPA_PLATFORMTHEME=gnome
    

    Running unset QT_QPA_PLATFORMTHEME before the test lets it run and pass. Maybe the test itself should be unsetting this variable in test_main.cpp, or maybe not if it is useful for QApplicationPrivate to be respecting local system settings. I just wanted to document this problem for now in case it affects anyone else.

  2. ryanofsky added the label Bug on Oct 2, 2021
  3. ryanofsky commented at 1:25 am on October 2, 2021: member
    Closing this issue I think because it is more appropriate to deal with it in the test environment than in the test itself. But could consider other solutions later.
  4. ryanofsky closed this on Oct 2, 2021

  5. fanquake commented at 2:35 am on October 2, 2021: member
  6. MarcoFalke added the label GUI on Oct 2, 2021
  7. hebasto commented at 7:31 am on October 3, 2021: member

    @ryanofsky

    May I ask you to share some details about your system: OS, desktop environment, Qt version (if non-static build)?

    So the failure happens loading gnome platform plugin, and apparently on my system this is enabled by an environment variable:

    0$ env | grep QPA
    1QT_QPA_PLATFORMTHEME=gnome
    

    Did you find out which installed package is responsible for setting QT_QPA_PLATFORMTHEME=gnome?

  8. ryanofsky commented at 2:22 pm on October 4, 2021: member

    Did you find out which installed package is responsible for setting QT_QPA_PLATFORMTHEME=gnome?

    It comes from the qt5 package here: https://github.com/NixOS/nixpkgs/blob/38501bec61c1e9447aa4ffc01ba07c40f4515327/nixos/modules/config/qt5.nix#L97

    We could unset this variable inside test_main.cpp. But I would be reluctant to do that because the test goes out of its way to respect the QT_QPA_PLATFORM when it is set, so it would be inconsistent for it to stop respecting QT_QPA_PLATFORMTHEME.

    Setting these variables is not necessarily useful if you only care about CI pass/fail results, but it can be useful if you want to observe or record what happens during the tests visually. I think the ideal fix for this problem would be implemented upstream in Qt. It should probably be a nonfatal error instead of a fatal error if QGuiApplicationPrivate::updatePalette() can’t connect to the gnome socket.

  9. DrahtBot locked this on Oct 30, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-06-29 07:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me