After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 791943 - gnome-shell built with meson hangs when opening more than one window
gnome-shell built with meson hangs when opening more than one window
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: .General
3.22.x
Other FreeBSD
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2017-12-25 15:27 UTC by Ting-Wei Lan
Modified: 2018-01-02 18:34 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
configure: Don't declare functions in AC_TRY_COMPILE and AC_LANG_PROGRAM (3.23 KB, patch)
2018-01-02 18:18 UTC, Ting-Wei Lan
committed Details | Review

Description Ting-Wei Lan 2017-12-25 15:27:01 UTC
This problem was reported in https://bugzilla.gnome.org/show_bug.cgi?id=785153#c4 shortly after autotools support was dropped. I know it is unusual for a change of build system to cause serious runtime issues, but porting to meson does changes the linker flags used to link gnome-shell.

When gnome-shell is built with meson, doing any of following things freezes the entire desktop:

1. Move mouse to 'Activities' when an application is running.
2. Use Alt+F2 to run another application when an application is running.
3. Open a new window or dialog from a running application.
4. Click any unfocused window.

When gnome-shell hangs, it stops responding on D-Bus interfaces and it seems that the only thing a user can do is to switch to another VT to kill it. This test was done on X11, so VT switch works and killing gnome-shell is safe.

Fortunately, I found some ways to avoid this problem. If I can get libgnome-shell-menu.so loaded before libgtk-3.so.0, gnome-shell can work without problems.

Doing any of the following things can avoid this issue:

1. Build with autotools by reverting commit 6d704cd, cf010cf, ab0e98d.
2. Set LD_PRELOAD=/path/to/libgnome-shell-menu.so environment variable.
3. Run 'patchelf --add-needed libgnome-shell-menu.so /path/to/gnome-shell'.
4. Edit src/meson.build to list libshell_menu_dep in the dependencies of gnome-shell and run meson with '-Db_asneeded=false'.

I don't know how can I fix this issue properly. libgnome-shell-menu.so has many symbols which also exist in libgtk-3.so.0 ...
Comment 1 Florian Müllner 2017-12-25 20:49:22 UTC
> When gnome-shell is built with meson, doing any of following things freezes the entire desktop

On affected systems like yours. There's more to it than just meson, otherwise we'd be swamped with reports given that (among others) Fedora and Ubuntu use a meson-built shell in their latest releases.
Comment 2 Ting-Wei Lan 2017-12-26 07:29:11 UTC
I believe this problem is caused by having the same symbols in libgnome-shell-menu.so and libgtk-3.so.0.

On working systems, gnome-shell uses gtk_action_muxer_*, gtk_action_observer_*, gtk_menu_tracker_* from libgnome-shell-menu.so.

On affected systems, most of these symbols are bound to libgtk-3.so.0 and only a few of them comes from libgnome-shell-menu.so.

Here is the list of 'T' symbols in libgnome-shell-menu.so:

_gtk_menu_tracker_item_get_observable
_gtk_menu_tracker_item_get_submenu
_gtk_menu_tracker_item_get_submenu_namespace
_gtk_menu_tracker_item_is_visible
_gtk_menu_tracker_item_may_disappear
_gtk_menu_tracker_item_new
gtk_action_muxer_get_parent
gtk_action_muxer_get_primary_accel
gtk_action_muxer_get_type
gtk_action_muxer_insert
gtk_action_muxer_new
gtk_action_muxer_remove
gtk_action_muxer_set_parent
gtk_action_muxer_set_primary_accel
gtk_action_observable_get_type
gtk_action_observable_register_observer
gtk_action_observable_unregister_observer
gtk_action_observer_action_added
gtk_action_observer_action_enabled_changed
gtk_action_observer_action_removed
gtk_action_observer_action_state_changed
gtk_action_observer_get_type
gtk_action_observer_primary_accel_changed
gtk_menu_tracker_free
gtk_menu_tracker_item_activated
gtk_menu_tracker_item_get_accel
gtk_menu_tracker_item_get_has_submenu
gtk_menu_tracker_item_get_icon
gtk_menu_tracker_item_get_is_separator
gtk_menu_tracker_item_get_label
gtk_menu_tracker_item_get_role
gtk_menu_tracker_item_get_sensitive
gtk_menu_tracker_item_get_should_request_show
gtk_menu_tracker_item_get_submenu_shown
gtk_menu_tracker_item_get_toggled
gtk_menu_tracker_item_get_type
gtk_menu_tracker_item_get_visible
gtk_menu_tracker_item_request_submenu_shown
gtk_menu_tracker_item_role_get_type
gtk_menu_tracker_new
gtk_menu_tracker_new_for_item_submenu
gtk_print_action_and_target

On Fedora, these symbols are bound to libgnome-shell-menu.so. We can check it by running gnome-shell with both LD_DEBUG=bindings and LD_BIND_NOW=1.

$ LD_DEBUG=bindings LD_BIND_NOW=1 gnome-shell --version
     32666:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `_gtk_menu_tracker_item_get_observable'
     32669:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `_gtk_menu_tracker_item_get_submenu'
     32669:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `_gtk_menu_tracker_item_get_submenu_namespace'
     32672:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `_gtk_menu_tracker_item_get_submenu_namespace'
     32675:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `_gtk_menu_tracker_item_is_visible'
     32678:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `_gtk_menu_tracker_item_may_disappear'
     32681:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `_gtk_menu_tracker_item_new'
     32684:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `gtk_action_muxer_get_parent'
     32687:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `gtk_action_muxer_get_primary_accel'
     32690:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `gtk_action_muxer_get_type'
     32693:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `gtk_action_muxer_insert'
     32696:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `gtk_action_muxer_new'
     32699:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `gtk_action_muxer_remove'
     32702:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `gtk_action_muxer_set_parent'
     32708:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `gtk_action_observable_get_type'
     32711:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `gtk_action_observable_register_observer'
     32717:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `gtk_action_observer_action_added'
     32720:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `gtk_action_observer_action_enabled_changed'
     32723:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `gtk_action_observer_action_removed'
     32726:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `gtk_action_observer_action_state_changed'
     32729:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `gtk_action_observer_get_type'
     32732:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `gtk_action_observer_primary_accel_changed'
     32735:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `gtk_menu_tracker_free'
     32741:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `gtk_menu_tracker_item_get_accel'
     32744:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `gtk_menu_tracker_item_get_has_submenu'
     32747:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `gtk_menu_tracker_item_get_icon'
     32750:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `gtk_menu_tracker_item_get_is_separator'
     32753:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `gtk_menu_tracker_item_get_label'
     32756:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `gtk_menu_tracker_item_get_role'
     32759:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `gtk_menu_tracker_item_get_sensitive'
     32765:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `gtk_menu_tracker_item_get_submenu_shown'
       300:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `gtk_menu_tracker_item_get_toggled'
       303:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `gtk_menu_tracker_item_get_type'
       306:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `gtk_menu_tracker_item_get_visible'
       312:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `gtk_menu_tracker_item_role_get_type'
       315:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `gtk_menu_tracker_new'
       315:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `gtk_menu_tracker_new_for_item_submenu'
       315:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `gtk_menu_tracker_new'
       318:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `gtk_menu_tracker_new_for_item_submenu'
       321:	binding file /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0] to /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so [0]: normal symbol `gtk_print_action_and_target'
GNOME Shell 3.27.1

On FreeBSD, most of these symbols are bound to libgtk-3.so.0 instead of libgnome-shell-menu.so when building with meson. We can check it by using gdb.

$ gdb gnome-shell
GNU gdb (GDB) 8.0.1 [GDB v8.0.1 for FreeBSD]
Reading symbols from gnome-shell...done.
(gdb) set env LD_BIND_NOW=1
(gdb) b _start
Breakpoint 1 at 0x401f54
(gdb) r
Starting program: /home/lantw44/gnome/devinstall/bin/gnome-shell

Breakpoint 1, 0x0000000000401f54 in _start ()
(gdb) pi
>>> for symbol in '_gtk_menu_tracker_item_get_observable _gtk_menu_tracker_item_get_submenu _gtk_menu_tracker_item_get_submenu_namespace _gtk_menu_tracker_item_is_visible _gtk_menu_tracker_item_may_disappear _gtk_menu_tracker_item_new gtk_action_muxer_get_parent gtk_action_muxer_get_primary_accel gtk_action_muxer_get_type gtk_action_muxer_insert gtk_action_muxer_new gtk_action_muxer_remove gtk_action_muxer_set_parent gtk_action_muxer_set_primary_accel gtk_action_observable_get_type gtk_action_observable_register_observer gtk_action_observable_unregister_observer gtk_action_observer_action_added gtk_action_observer_action_enabled_changed gtk_action_observer_action_removed gtk_action_observer_action_state_changed gtk_action_observer_get_type gtk_action_observer_primary_accel_changed gtk_menu_tracker_free gtk_menu_tracker_item_activated gtk_menu_tracker_item_get_accel gtk_menu_tracker_item_get_has_submenu gtk_menu_tracker_item_get_icon gtk_menu_tracker_item_get_is_separator gtk_menu_tracker_item_get_label gtk_menu_tracker_item_get_role gtk_menu_tracker_item_get_sensitive gtk_menu_tracker_item_get_should_request_show gtk_menu_tracker_item_get_submenu_shown gtk_menu_tracker_item_get_toggled gtk_menu_tracker_item_get_type gtk_menu_tracker_item_get_visible gtk_menu_tracker_item_request_submenu_shown gtk_menu_tracker_item_role_get_type gtk_menu_tracker_new gtk_menu_tracker_new_for_item_submenu gtk_print_action_and_target'.split(' '):
...     gdb.execute('info symbol {}'.format(symbol))
...
_gtk_menu_tracker_item_get_observable in section .text of /home/lantw44/gnome/devinstall/lib/libgtk-3.so.0
_gtk_menu_tracker_item_get_submenu in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
_gtk_menu_tracker_item_get_submenu_namespace in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
_gtk_menu_tracker_item_is_visible in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
_gtk_menu_tracker_item_may_disappear in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
_gtk_menu_tracker_item_new in section .text of /home/lantw44/gnome/devinstall/lib/libgtk-3.so.0
gtk_action_muxer_get_parent in section .text of /home/lantw44/gnome/devinstall/lib/libgtk-3.so.0
gtk_action_muxer_get_primary_accel in section .text of /home/lantw44/gnome/devinstall/lib/libgtk-3.so.0
gtk_action_muxer_get_type in section .text of /home/lantw44/gnome/devinstall/lib/libgtk-3.so.0
gtk_action_muxer_insert in section .text of /home/lantw44/gnome/devinstall/lib/libgtk-3.so.0
gtk_action_muxer_new in section .text of /home/lantw44/gnome/devinstall/lib/libgtk-3.so.0
gtk_action_muxer_remove in section .text of /home/lantw44/gnome/devinstall/lib/libgtk-3.so.0
gtk_action_muxer_set_parent in section .text of /home/lantw44/gnome/devinstall/lib/libgtk-3.so.0
gtk_action_muxer_set_primary_accel in section .text of /home/lantw44/gnome/devinstall/lib/libgtk-3.so.0
gtk_action_observable_get_type in section .text of /home/lantw44/gnome/devinstall/lib/libgtk-3.so.0
gtk_action_observable_register_observer in section .text of /home/lantw44/gnome/devinstall/lib/libgtk-3.so.0
gtk_action_observable_unregister_observer in section .text of /home/lantw44/gnome/devinstall/lib/libgtk-3.so.0
gtk_action_observer_action_added in section .text of /home/lantw44/gnome/devinstall/lib/libgtk-3.so.0
gtk_action_observer_action_enabled_changed in section .text of /home/lantw44/gnome/devinstall/lib/libgtk-3.so.0
gtk_action_observer_action_removed in section .text of /home/lantw44/gnome/devinstall/lib/libgtk-3.so.0
gtk_action_observer_action_state_changed in section .text of /home/lantw44/gnome/devinstall/lib/libgtk-3.so.0
gtk_action_observer_get_type in section .text of /home/lantw44/gnome/devinstall/lib/libgtk-3.so.0
gtk_action_observer_primary_accel_changed in section .text of /home/lantw44/gnome/devinstall/lib/libgtk-3.so.0
gtk_menu_tracker_free in section .text of /home/lantw44/gnome/devinstall/lib/libgtk-3.so.0
gtk_menu_tracker_item_activated in section .text of /home/lantw44/gnome/devinstall/lib/libgtk-3.so.0
gtk_menu_tracker_item_get_accel in section .text of /home/lantw44/gnome/devinstall/lib/libgtk-3.so.0
gtk_menu_tracker_item_get_has_submenu in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_menu_tracker_item_get_icon in section .text of /home/lantw44/gnome/devinstall/lib/libgtk-3.so.0
gtk_menu_tracker_item_get_is_separator in section .text of /home/lantw44/gnome/devinstall/lib/libgtk-3.so.0
gtk_menu_tracker_item_get_label in section .text of /home/lantw44/gnome/devinstall/lib/libgtk-3.so.0
gtk_menu_tracker_item_get_role in section .text of /home/lantw44/gnome/devinstall/lib/libgtk-3.so.0
gtk_menu_tracker_item_get_sensitive in section .text of /home/lantw44/gnome/devinstall/lib/libgtk-3.so.0
gtk_menu_tracker_item_get_should_request_show in section .text of /home/lantw44/gnome/devinstall/lib/libgtk-3.so.0
gtk_menu_tracker_item_get_submenu_shown in section .text of /home/lantw44/gnome/devinstall/lib/libgtk-3.so.0
gtk_menu_tracker_item_get_toggled in section .text of /home/lantw44/gnome/devinstall/lib/libgtk-3.so.0
---Type <return> to continue, or q <return> to quit---
gtk_menu_tracker_item_get_type in section .text of /home/lantw44/gnome/devinstall/lib/libgtk-3.so.0
gtk_menu_tracker_item_get_visible in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_menu_tracker_item_request_submenu_shown in section .text of /home/lantw44/gnome/devinstall/lib/libgtk-3.so.0
gtk_menu_tracker_item_role_get_type in section .text of /home/lantw44/gnome/devinstall/lib/libgtk-3.so.0
gtk_menu_tracker_new in section .text of /home/lantw44/gnome/devinstall/lib/libgtk-3.so.0
gtk_menu_tracker_new_for_item_submenu in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_print_action_and_target in section .text of /home/lantw44/gnome/devinstall/lib/libgtk-3.so.0

If we add libgnome-shell-menu.so to DT_NEEDED by using patchelf, gnome-shell can work without problems and we can see it correctly uses these symbols from libgnome-shell-menu.so.

$ cp $(which gnome-shell) $(which gnome-shell)-patched
$ patchelf --add-needed libgnome-shell-menu.so $(which gnome-shell-patched)
$ gdb gnome-shell-patched
GNU gdb (GDB) 8.0.1 [GDB v8.0.1 for FreeBSD]
Reading symbols from gnome-shell-patched...done.
(gdb) set env LD_BIND_NOW=1
(gdb) b _start
Breakpoint 1 at 0x401f54
(gdb) r
Starting program: /home/lantw44/gnome/devinstall/bin/gnome-shell-patched

Breakpoint 1, 0x0000000000401f54 in _start ()
(gdb) pi
>>> for symbol in '_gtk_menu_tracker_item_get_observable _gtk_menu_tracker_item_get_submenu _gtk_menu_tracker_item_get_submenu_namespace _gtk_menu_tracker_item_is_visible _gtk_menu_tracker_item_may_disappear _gtk_menu_tracker_item_new gtk_action_muxer_get_parent gtk_action_muxer_get_primary_accel gtk_action_muxer_get_type gtk_action_muxer_insert gtk_action_muxer_new gtk_action_muxer_remove gtk_action_muxer_set_parent gtk_action_muxer_set_primary_accel gtk_action_observable_get_type gtk_action_observable_register_observer gtk_action_observable_unregister_observer gtk_action_observer_action_added gtk_action_observer_action_enabled_changed gtk_action_observer_action_removed gtk_action_observer_action_state_changed gtk_action_observer_get_type gtk_action_observer_primary_accel_changed gtk_menu_tracker_free gtk_menu_tracker_item_activated gtk_menu_tracker_item_get_accel gtk_menu_tracker_item_get_has_submenu gtk_menu_tracker_item_get_icon gtk_menu_tracker_item_get_is_separator gtk_menu_tracker_item_get_label gtk_menu_tracker_item_get_role gtk_menu_tracker_item_get_sensitive gtk_menu_tracker_item_get_should_request_show gtk_menu_tracker_item_get_submenu_shown gtk_menu_tracker_item_get_toggled gtk_menu_tracker_item_get_type gtk_menu_tracker_item_get_visible gtk_menu_tracker_item_request_submenu_shown gtk_menu_tracker_item_role_get_type gtk_menu_tracker_new gtk_menu_tracker_new_for_item_submenu gtk_print_action_and_target'.split(' '):
...     gdb.execute('info symbol {}'.format(symbol))
...
_gtk_menu_tracker_item_get_observable in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
_gtk_menu_tracker_item_get_submenu in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
_gtk_menu_tracker_item_get_submenu_namespace in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
_gtk_menu_tracker_item_is_visible in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
_gtk_menu_tracker_item_may_disappear in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
_gtk_menu_tracker_item_new in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_action_muxer_get_parent in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_action_muxer_get_primary_accel in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_action_muxer_get_type in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_action_muxer_insert in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_action_muxer_new in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_action_muxer_remove in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_action_muxer_set_parent in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_action_muxer_set_primary_accel in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_action_observable_get_type in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_action_observable_register_observer in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_action_observable_unregister_observer in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_action_observer_action_added in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_action_observer_action_enabled_changed in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_action_observer_action_removed in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_action_observer_action_state_changed in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_action_observer_get_type in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_action_observer_primary_accel_changed in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_menu_tracker_free in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_menu_tracker_item_activated in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_menu_tracker_item_get_accel in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_menu_tracker_item_get_has_submenu in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_menu_tracker_item_get_icon in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_menu_tracker_item_get_is_separator in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_menu_tracker_item_get_label in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_menu_tracker_item_get_role in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_menu_tracker_item_get_sensitive in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_menu_tracker_item_get_should_request_show in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_menu_tracker_item_get_submenu_shown in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_menu_tracker_item_get_toggled in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
---Type <return> to continue, or q <return> to quit---
gtk_menu_tracker_item_get_type in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_menu_tracker_item_get_visible in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_menu_tracker_item_request_submenu_shown in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_menu_tracker_item_role_get_type in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_menu_tracker_new in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_menu_tracker_new_for_item_submenu in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so
gtk_print_action_and_target in section .text of /home/lantw44/gnome/devinstall/lib/gnome-shell/libgnome-shell-menu.so

Is it possible to avoid using conflicting symbols in libgnome-shell-menu.so?
Comment 3 Ting-Wei Lan 2018-01-02 18:17:08 UTC
Move to GTK+ because the conflicting symbols problem is caused by the wrong usage of AC_TRY_COMPILE and AC_LANG_PROGRAM macros in configure.ac of gtk3.

This problem is already found by OpenBSD developers and it is already patched in OpenBSD ports.

https://undeadly.org/cgi?action=article;sid=20170930133438
https://cvsweb.openbsd.org/cgi-bin/cvsweb/ports/x11/gtk%2b3/patches/patch-configure?rev=1.15&content-type=text/x-cvsweb-markup

Both AC_TRY_COMPILE and AC_LANG_PROGRAM put code to test in the main function, so instead of using 'int main (void) { return 0; }' as test program, we must use 'return 0' and no function can be declared. If we declare main function there, it becomes a nested main function inside the global main function. It is supported by GCC, but not by Clang.

This causes problems when checking compiler flags:

checking for -fvisibility=hidden compiler flag... no
checking for -Bsymbolic-functions linker flag... no

Open config.log and we can find these error messages:

configure:29131: checking for -fvisibility=hidden compiler flag
configure:29144: clang -c -fvisibility=hidden -I/usr/local/include -D_THREAD_SAFE -pthread  conftest.c >&5
conftest.c:83:17: error: function definition is not allowed here
int main (void) { return 0; }
                ^
1 error generated.
configure:29144: $? = 1
configure: failed program was:
| int
| main ()
| {
| int main (void) { return 0; }
|   ;
|   return 0;
| }
configure:29149: result: no

Therefore, symbols that should be hidden are visible to other programs, causing conflicts with the private GNOME Shell library libgnome-shell-menu.so.
Comment 4 Ting-Wei Lan 2018-01-02 18:18:26 UTC
Created attachment 366212 [details] [review]
configure: Don't declare functions in AC_TRY_COMPILE and AC_LANG_PROGRAM

Both AC_TRY_COMPILE and AC_LANG_PROGRAM put code passed to their second
arguments to the body of the main function. This means that we cannot
and should not declare functions there, or we end up checking whether
the compiler support nested functions instead of whether a compiler or
linker flag is supported.

GCC supports nested functions and tests succeed. Clang doesn't support
nested functions, so tests fail and -fvisibility=hidden won't be used.
This means that functions which are not intended to be used by other
programs, such as gtk_menu_tracker*, gtk_action_observ*,
gtk_menu_muxer_*, become global symbols with default visibility.

GNOME Shell has a private library libgnome-shell-menu.so, which also has
symbols gtk_menu_tracker*, gtk_action_observ*, gtk_menu_muxer_* that are
intended to be used by GNOME Shell itself. When GNOME Shell still used
Autotools build system, the executable gnome-shell explicitly linked to
libgnome-shell-menu.so, so the linker loaded libgnome-shell-menu.so
before libgtk-3.so.0 and GNOME Shell used correct symbols from its
private library.

However, after GNOME Shell switched to Meson build system, gnome-shell
executable no longer lists libgnome-shell-menu.so as its dependency.
Even if we adds it to the build file, it won't be listed in DT_NEEDED of
gnome-shell because Meson uses -Wl,--as-needed by default. This causes
the runtime linker to load libgtk-3.so.0 before libgnome-shell-menu.so
and symbols gtk_menu_tracker*, gtk_action_observ*, gtk_menu_muxer_* are
bound to libgtk-3.so.0 instead of libgnome-shell-menu.so. GNOME Shell
hangs when opening more than one window because it uses functions from
the wrong library.

This problem is already fixed in OpenBSD ports. The article describing
it can be found on OpenBSD Journal with this link:
https://undeadly.org/cgi?action=article;sid=20170930133438
Comment 5 Emmanuele Bassi (:ebassi) 2018-01-02 18:29:17 UTC
Review of attachment 366212 [details] [review]:

This is obviously correct; thanks for the patch, for the detective work, and the excellent commit message.
Comment 6 Ting-Wei Lan 2018-01-02 18:34:15 UTC
Attachment 366212 [details] pushed as 31f7b55 - configure: Don't declare functions in AC_TRY_COMPILE and AC_LANG_PROGRAM