Bug 256293 - editors/lazarus-qt5 - Not working with Wayland (sway)
Summary: editors/lazarus-qt5 - Not working with Wayland (sway)
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Jose Alonso Cardenas Marquez
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-05-31 13:41 UTC by Stephan Lichtenauer
Modified: 2021-06-01 20:23 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (acm)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stephan Lichtenauer 2021-05-31 13:41:11 UTC
If I start lazarus-qt5-2.0.10_1 (installed from packages) under sway (Wayland) and FreeBSD 13 with i915 KMS drivers, lazarus fails to start with an exception (before any window appears):

$ lazarus
[FORMS.PP] ExceptionOccurred
  Sender=EAccessViolation
  Exception=Access violation
  Stack trace:
  $000000000044F43C
  $00007FFFFFFFF003
  $0000000000572469
  $00000000006FCAC8
  $00000000006FC45A
  $00000000006F807C
  $0000000000600B99
  $0000000000600A9F
  $000000000048D83A
[FORMS.PP] ExceptionOccurred


If I force Lazarus to use the X11 backend with the following command, Lazarus works fine, so the error is very likely related to the Wayland backend:

$ QT_QPA_PLATFORM=xcb lazarus
Comment 1 Jan Beich freebsd_committer freebsd_triage 2021-05-31 19:37:22 UTC
Some notes:
- kwin_wayland (from x11-wm/plasma5-kwin) and https://github.com/unrelentingtech/weston are affected as well
- setting XDG_CURRENT_DESKTOP=GNOME via environ(7) launches lazarus via QT_QPA_PLATFORM=xcb (Xwayland)
- lazarus-qt5 built WITH_DEBUG=1 shows better stacktrace
- running from lldb/gdb hints at direct X11 calls that but (a) Xwayland maybe disabled (b) Xwayland -rootless relies on Wayland compositor for WM interop

$ WAYLAND_DEBUG=1 lazarus
[0.733]  -> wl_display@1.get_registry(new id wl_registry@2)
[0.805]  -> wl_display@1.sync(new id wl_callback@3)
[0.876] wl_display@1.delete_id(3)
[0.885] wl_registry@2.global(1, "wl_shm", 1)
[0.894]  -> wl_registry@2.bind(1, "wl_shm", 1, new id [unknown]@4)
[0.901] wl_registry@2.global(2, "wl_drm", 2)
[0.907] wl_registry@2.global(3, "zwp_linux_dmabuf_v1", 3)
[0.913] wl_registry@2.global(4, "wl_compositor", 4)
[0.918]  -> wl_registry@2.bind(4, "wl_compositor", 3, new id [unknown]@5)
[0.924] wl_registry@2.global(5, "wl_subcompositor", 1)
[0.929]  -> wl_registry@2.bind(5, "wl_subcompositor", 1, new id [unknown]@6)
[0.936] wl_registry@2.global(6, "wl_data_device_manager", 3)
[0.942]  -> wl_registry@2.bind(6, "wl_data_device_manager", 1, new id [unknown]@7)
[0.948] wl_registry@2.global(7, "zwlr_gamma_control_manager_v1", 1)
[0.953] wl_registry@2.global(8, "zxdg_output_manager_v1", 3)
[0.960]  -> wl_registry@2.bind(8, "zxdg_output_manager_v1", 3, new id [unknown]@8)
[0.966]  -> wl_display@1.sync(new id wl_callback@9)
[0.970] wl_registry@2.global(9, "org_kde_kwin_idle", 1)
[0.976] wl_registry@2.global(10, "zwp_idle_inhibit_manager_v1", 1)
[0.982] wl_registry@2.global(11, "zwlr_layer_shell_v1", 4)
[0.987] wl_registry@2.global(12, "xdg_wm_base", 2)
[0.993] wl_registry@2.global(13, "zwp_tablet_manager_v2", 1)
[0.999]  -> wl_registry@2.bind(13, "zwp_tablet_manager_v2", 1, new id [unknown]@10)
[1.007] wl_registry@2.global(14, "org_kde_kwin_server_decoration_manager", 1)
[1.012] wl_registry@2.global(15, "zxdg_decoration_manager_v1", 1)
[1.021] wl_registry@2.global(16, "zwp_relative_pointer_manager_v1", 1)
[1.026] wl_registry@2.global(17, "zwp_pointer_constraints_v1", 1)
[1.032] wl_registry@2.global(18, "wp_presentation", 1)
[1.037] wl_registry@2.global(19, "zwlr_output_manager_v1", 2)
[1.043] wl_registry@2.global(20, "zwlr_output_power_manager_v1", 1)
[1.048] wl_registry@2.global(21, "zwp_input_method_manager_v2", 1)
[1.053] wl_registry@2.global(22, "zwp_text_input_manager_v3", 1)
[1.059] wl_registry@2.global(23, "zwlr_foreign_toplevel_manager_v1", 3)
[1.064] wl_registry@2.global(24, "zwlr_export_dmabuf_manager_v1", 1)
[1.070] wl_registry@2.global(25, "zwlr_screencopy_manager_v1", 3)
[1.075] wl_registry@2.global(26, "zwlr_data_control_manager_v1", 2)
[1.080] wl_registry@2.global(27, "zwp_primary_selection_device_manager_v1", 1)
[1.086]  -> wl_registry@2.bind(27, "zwp_primary_selection_device_manager_v1", 1, new id [unknown]@11)
[1.093] wl_registry@2.global(28, "wp_viewporter", 1)
[1.098] wl_registry@2.global(29, "zxdg_exporter_v1", 1)
[1.104] wl_registry@2.global(30, "zxdg_importer_v1", 1)
[1.109] wl_registry@2.global(31, "zxdg_exporter_v2", 1)
[1.118] wl_registry@2.global(32, "zxdg_importer_v2", 1)
[1.124] wl_registry@2.global(33, "zwp_virtual_keyboard_manager_v1", 1)
[1.130] wl_registry@2.global(34, "zwlr_virtual_pointer_manager_v1", 2)
[1.135] wl_registry@2.global(35, "zwlr_input_inhibit_manager_v1", 1)
[1.140] wl_registry@2.global(36, "zwp_keyboard_shortcuts_inhibit_manager_v1", 1)
[1.146] wl_registry@2.global(37, "wl_seat", 7)
[1.151]  -> wl_registry@2.bind(37, "wl_seat", 5, new id [unknown]@12)
[1.159]  -> wl_data_device_manager@7.get_data_device(new id wl_data_device@13, wl_seat@12)
[1.164]  -> zwp_primary_selection_device_manager_v1@11.get_device(new id zwp_primary_selection_device_v1@14, wl_seat@12)
[1.170]  -> zwp_tablet_manager_v2@10.get_tablet_seat(new id zwp_tablet_seat_v2@15, wl_seat@12)
[1.175] wl_registry@2.global(38, "zwp_pointer_gestures_v1", 1)
[1.180] wl_registry@2.global(39, "wl_output", 3)
[1.187]  -> wl_registry@2.bind(39, "wl_output", 2, new id [unknown]@16)
[1.198]  -> zxdg_output_manager_v1@8.get_xdg_output(new id zxdg_output_v1@17, wl_output@16)
[1.203] wl_callback@3.done(12456)
[1.252] wl_display@1.delete_id(9)
[1.256] wl_shm@4.format(0)
[1.259] wl_shm@4.format(1)
[1.261] wl_shm@4.format(875709016)
[1.263] wl_shm@4.format(875708993)
[1.265] wl_callback@9.done(12456)
[1.267] wl_seat@12.name("seat0")
[1.269] wl_seat@12.capabilities(3)
[1.277]  -> wl_seat@12.get_keyboard(new id wl_keyboard@9)
[1.282]  -> wl_seat@12.get_pointer(new id wl_pointer@3)
[1.285] wl_output@16.geometry(0, 0, 600, 340, 2, "Goldstar Company Ltd", "LG Ultra HD", 0)
[1.295] wl_output@16.mode(1, 3840, 2160, 60000)
[1.300] wl_output@16.scale(1)
[1.303] wl_output@16.done()
[1.329] zxdg_output_v1@17.name("DP-1")
[1.333] zxdg_output_v1@17.description("Goldstar Company Ltd LG Ultra HD 0x0000C784 (DP-1)")
[1.336] zxdg_output_v1@17.logical_position(0, 0)
[1.339] zxdg_output_v1@17.logical_size(3840, 2160)
[1.341] wl_output@16.done()
[FORMS.PP] ExceptionOccurred
  Sender=EAccessViolation
  Exception=Access violation
  Stack trace:
  $000000000044F3FC
  $00007FFFFFFFF003
  $0000000000572419  COLORTORGB,  line 2531 of graphics.pp
  $00000000006FCA78  CREATEOBJECTS,  line 2363 of qtobjects.pas
  $00000000006FC40A  CREATE,  line 2271 of qtobjects.pas
  $00000000006F802C  QTDEFAULTCONTEXT,  line 919 of qtobjects.pas
  $0000000000600B49  DESTROY,  line 93 of qtobject.inc
  $0000000000600A4F  CREATE,  line 70 of qtobject.inc
  $000000000048D7FA  CREATEWIDGETSET,  line 2223 of forms.pp
[FORMS.PP] ExceptionOccurred

$ (cd /usr/local/share/lazarus-* && lldb ./startlazarus)
(lldb) run
Process 48202 launching
Process 48202 stopped
* thread #1, name = 'startlazarus', stop reason = signal SIGBUS
    frame #0: 0x0000000801044516 libX11.so.6`_XInternAtom(dpy=0x00000008045a6600, name="_NET_WM_DESKTOP", onlyIfExists=1, psig=0x00007fffffffe830, pidx=0x00007fffffffe82c, pn=0x00007fffffffe828) at IntAtom.c:77:25
   74       /* look in the cache first */
   75       if (!(atoms = dpy->atoms)) {
   76           dpy->atoms = atoms = Xcalloc(1, sizeof(AtomTable));
-> 77           dpy->free_funcs->atoms = _XFreeAtomTable;
   78       }
   79       sig = 0;
   80       for (s1 = (char *)name; (c = *s1++); )
(lldb) bt
* thread #1, name = 'startlazarus', stop reason = signal SIGBUS
  * frame #0: 0x0000000801044516 libX11.so.6`_XInternAtom(dpy=0x00000008045a6600, name="_NET_WM_DESKTOP", onlyIfExists=1, psig=0x00007fffffffe830, pidx=0x00007fffffffe82c, pn=0x00007fffffffe828) at IntAtom.c:77:25
    frame #1: 0x0000000801044339 libX11.so.6`XInternAtom(dpy=0x00000008045a6600, name="_NET_WM_DESKTOP", onlyIfExists=1) at IntAtom.c:176:17
    frame #2: 0x00000000006c5d90 startlazarus`XLIB_$$_XINTERNATOM$PDISPLAY$PCHAR$BOOLEAN$$QWORD + 16
    frame #3: 0x0000000000600044 startlazarus`GETWINDOWMANAGER at qtx11.inc:208:13
    frame #4: 0x00000000006008dd startlazarus`CREATE(this=0x000000080452dd10, vmt=0x0000000000000001) at qtobject.inc:58:51
    frame #5: 0x000000000048d7fa startlazarus`CREATEWIDGETSET(AWIDGETSETCLASS=0x0000000000bc7a60) at forms.pp:2223:31
    frame #6: 0x0000000000454b13 startlazarus`INTERFACES_$$_init$ at interfaces.pp:36:31
    frame #7: 0x0000000000440932 startlazarus`fpc_initializeunits + 98
    frame #8: 0x0000000000423212 startlazarus`main at startlazarus.lpr:45:1
(lldb) f 3
frame #3: 0x0000000000600044 startlazarus`GETWINDOWMANAGER at qtx11.inc:208:13
   201    Display := QX11Info_display();
   202
   203    if Display = nil then
   204      exit;
   205
   206    ScreenNum := QX11Info_appScreen();
   207    RootWin := XRootWindow(Display, ScreenNum);
-> 208    WMAtom := XInternAtom(Display,'_NET_WM_DESKTOP', True);
   209
   210    if WMAtom > 0 then
   211    begin
   212      WMAtom := XInternAtom(Display,'_NET_SUPPORTING_WM_CHECK', False);
   213      if WMAtom > 0 then
   214      begin
   215        data := nil;
(lldb) f 4
frame #4: 0x00000000006008dd startlazarus`CREATE(this=0x000000080452dd10, vmt=0x0000000000000001) at qtobject.inc:58:51
   53     FAppActive := False;
   54     {$IFDEF HASX11}
   55     SavedHintHandlesList := TFPList.Create;
   56     FMinimizedByPager := False;
   57     FLastMinimizeEvent := 0;
-> 58     FWindowManagerName := LowerCase(GetWindowManager);
   59     // metacity wm forks. marco = mint mate wm, gnome shell = gnome 3 wm
   60     if (FWindowManagerName = 'marco') or (FWindowManagerName = 'gnome shell') or
   61       (UTF8Pos('mutter', FWindowManagerName) > 0) then
   62       FWindowManagerName := 'metacity';
   63     {$ENDIF}
Comment 2 Jan Beich freebsd_committer freebsd_triage 2021-06-01 20:23:02 UTC
(In reply to Jan Beich from comment #1)
> - setting XDG_CURRENT_DESKTOP=GNOME via environ(7) launches lazarus via QT_QPA_PLATFORM=xcb (Xwayland)

Caused by https://codereview.qt-project.org/c/qt/qtbase/+/231227