Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

commit @de0a8da broke the wayland backend #1286

Open
KyunLFA opened this issue May 7, 2024 · 17 comments
Open

commit @de0a8da broke the wayland backend #1286

KyunLFA opened this issue May 7, 2024 · 17 comments

Comments

@KyunLFA
Copy link

KyunLFA commented May 7, 2024

Self explanatory.

Backtrace:

#0  0x000076579d6a053b in pthread_kill () at /usr/lib/libc.so.6
#1  0x000076579d642048 in raise () at /usr/lib/libc.so.6
#2  0x000076579d624478 in abort () at /usr/lib/libc.so.6
#3  0x000076579da97b6e in __gnu_cxx::__verbose_terminate_handler () at /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/vterminate.cc:95
#4  0x000076579daacd4c in __cxxabiv1::__terminate (handler=<optimized out>) at /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:48
#5  0x000076579daacdb9 in std::terminate () at /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:58
#6  0x000076579daad04c in __cxxabiv1::__cxa_throw
    (obj=<optimized out>, tinfo=0x5e04ea277ec0 <typeinfo for std::bad_variant_access>, dest=0x5e04ea079b30 <std::bad_variant_access::~bad_variant_access()>)
    at /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/eh_throw.cc:98
#7  0x00005e04ea079aed in std::__throw_bad_variant_access (__what=0x5e04e9ecce26 "std::get: wrong index for variant")
    at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/variant:1349
#8  0x00005e04ea079a60 in std::__throw_bad_variant_access (__valueless=false) at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/variant:1357
#9  0x00005e04ea0799ff in std::get<0ul, steamcompmgr_xwayland_win_t, steamcompmgr_xdg_win_t> (__v=std::variant [index 1] = {...})
    at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/variant:1716
#10 0x00005e04ea0799bd in std::get<steamcompmgr_xwayland_win_t, steamcompmgr_xwayland_win_t, steamcompmgr_xdg_win_t> (__v=std::variant [index 1] = {...})
    at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/variant:1155
#11 0x00005e04ea073b3c in steamcompmgr_win_t::xwayland (this=0x5e0513d46240) at ../gamescope/src/steamcompmgr_shared.hpp:138
#12 0x00005e04ea04e60a in determine_and_apply_focus () at ../gamescope/src/steamcompmgr.cpp:3595

bad_variant_access strikes again!

(edit: wow, github does not want to pretty parse the commit in the title. It's this de0a8da .

@KyunLFA KyunLFA changed the title https://github.com/ValveSoftware/gamescope/commit/de0a8daea6003cbb63fa1ec58bb00e2670f9da44 broke the wayland backend commit #de0a8da broke the wayland backend May 7, 2024
@KyunLFA KyunLFA changed the title commit #de0a8da broke the wayland backend commit @de0a8da broke the wayland backend May 7, 2024
@sharkautarch
Copy link

@KyunLFA
Simple workaround is to just check the type member and not execute the block of code accessing xwayland():
https://github.com/sharkautarch/gamescope/tree/fix_wayland_backend_bug

Not sure if this is a full solution tho, since maybe it's possible that before de0a8da, determine_and_apply_focus(xwayland_ctx_t *,std::vector<steamcompmgr_win_t*>&) might have still been applying mouse cursor warp to the root xwayland window even on the wayland backend??? I have no clue honestly

@repomansez
Copy link

repomansez commented May 7, 2024

Replying to #1286 (comment)

I applied this patch on my machine but I'm still having issues. Not sure if related, though, here's the full strace if you could maybe have a look:

strace.txt

@sharkautarch
Copy link

sharkautarch commented May 7, 2024

Replying to #1286 (comment)

Hmmm weird
does it also crash when you run gamescope -- glxgears?

also, try rebuilding gamescope with these meson flags: -Db_sanitize=address,undefined --buildtype=debugoptimized
also if you are building gamescope w/ PKGBUILD, add in this option line: options=(!strip)

Then when you run gamescope, add in these environment variables: ASAN_OPTIONS="detect_leaks=0 halt_on_error=0" LD_PRELOAD=/usr/lib/libasan.so.8.0.0 (so gamescope -- glxgears would become ASAN_OPTIONS="detect_leaks=0 halt_on_error=0" LD_PRELOAD=/usr/lib/libasan.so.8.0.0 gamescope -- glxgears)
That should provide more info

@repomansez
Copy link

does it also crash when you run gamescope -- glxgears?

Yes, it does, in fact it segfaults even if I only run gamescope itself.

I'm using Gentoo, compiled and ran with the flags you asked, and here's the full strace output, let me know if there's anything else I can run that may help debugging :)
obs: for some reason I was not able to compile with -Db_sanitize=address,undefined as it gave me ../gamescope-3.14.12/subprojects/wlroots/backend/wayland/seat.c:49:9: error: ‘memcpy’ specified bound 18446744073709551612 exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=]

Not sure if that's a problem with my setup or something else.

strace.txt

@sharkautarch
Copy link

sharkautarch commented May 7, 2024

for some reason I was not able to compile with -Db_sanitize=address,undefined as it gave me ../gamescope-3.14.12/subprojects/wlroots/backend/wayland/seat.c:49:9: error: ‘memcpy’ specified bound 18446744073709551612 exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=]

Not sure if that's a problem with my setup or something else.

Oh that's just a weird quirk with the sanitizer
Just add these additional meson flags: -Dc_args="-g1 -Wno-error=stringop-overflow -Wno-error=unused-but-set-variable -Wno-error=unused-variable -fno-omit-frame-pointer" -Dc_link_args="-Wno-error=stringop-overflow -g1 -Wno-error=unused-but-set-variable -Wno-error=unused-variable -fno-omit-frame-pointer" -Dcpp_args="-Wno-error=stringop-overflow -g1 -Wno-error=unused-but-set-variable -Wno-error=unused-variable -fno-omit-frame-pointer" -Dcpp_link_args="-Wno-error=stringop-overflow -g1 -Wno-error=unused-but-set-variable -Wno-error=unused-variable -fno-omit-frame-pointer"

Also, when you run gamescope after compiling it with the sanitizer, don't run it with strace, because it might either conflict with address sanitizer or cause gamescope to exit earlier than usual

@repomansez
Copy link

repomansez commented May 7, 2024

Replying to #1286 (comment)

Ok, was able to build it now, here's the output of gamescope -- glxgears: https://pastebin.com/raw/w1NXDJZD

Just reminding that this is a build built with fix_wayland_backend_bug patch applied

@sharkautarch
Copy link

sharkautarch commented May 7, 2024

#0 0x7d50079c3506  (/usr/lib64/libdecor/plugins-1/libdecor-cairo.so+0x7506)
#1 0x7d50079c402b  (/usr/lib64/libdecor/plugins-1/libdecor-cairo.so+0x802b)
#2 0x7d500a0a880b  (/usr/lib64/libdecor-0.so.0+0x380b)
#3 0x5c943d4809e3  (/usr/bin/gamescope+0x1c5e9e3)
#4 0x5c943d496f7a  (/usr/bin/gamescope+0x1c74f7a)
#5 0x5c943d09ba2c  (/usr/bin/gamescope+0x1879a2c)
#6 0x5c943d1c0d1d  (/usr/bin/gamescope+0x199ed1d)
#7 0x7d5009eff392  (/usr/lib/gcc/x86_64-pc-linux-gnu/13/libstdc++.so.6+0xe1392)
#8 0x7d50095d3340  (/usr/lib64/libc.so.6+0x88340)
#9 0x7d5009645e1b  (/usr/lib64/libc.so.6+0xfae1b)

HUH, it's segfaulting in /usr/lib64/libdecor-0.so.0...
Ok well I'm stumped...
@Joshua-Ashton do you have any clue about how this could be happening??!?!?!?

also, @repomansez I think your gentoo build thingy is stripping debug info from gamescope
Reason why I'm thinking that's the case is because I don't see any line numbers in the sanitizer logs, which iirc happens when binaries are stripped
it looks like you can configure your build script to not strip gamescope w/ the RESTRICT variable: https://devmanual.gentoo.org/ebuild-writing/variables/#ebuild-defined-variables

@repomansez
Copy link

repomansez commented May 7, 2024

Replying to #1286 (comment)

Well, I manually set it to restrict stripping, but that apparently did not help as it's outputting basically the same thing:

https://pastebin.com/raw/EzzZ1qDk

@sharkautarch
Copy link

sharkautarch commented May 7, 2024

Replying to #1286 (comment)

HUH weird...
what does running file $(which gamescope) give you?

@repomansez
Copy link

repomansez commented May 7, 2024

Replying to #1286 (comment)

/usr/bin/gamescope: executable, regular file, no read permission

@sharkautarch
Copy link

sharkautarch commented May 7, 2024

Replying to #1286 (comment)

ummm I guess gentoo uses a drastically different find program than other distros? because here's an example of what's shown on my archlinux system:
usr/bin/gamescope: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=2ddd0073a4f7bb5d71dde186fef4f00703cf147e, for GNU/Linux 4.4.0, not stripped

try running objdump --syms $(which gamescope)
if it doesn't just say something like "no symbols", try also running:
objdump --syms $(which gamescope) | grep debug

@repomansez
Copy link

repomansez commented May 7, 2024

Replying to #1286 (comment)

objdump --syms $(which gamescope) | grep debug

0000000003edf4e0 l O .bss 0000000000000001 ZL11debugEvents
0000000003edf520 l O .bss 0000000000000001 ZL10debugFocus
000000000162aed9 l F .text 0000000000000024 push_gles2_debug
.cold
0000000002272920 l F .text 000000000000055f debug_callback
0000000002637b80 l O .rodata 0000000000000048 debug_attribs.5
00000000022419c0 g F .text 0000000000000254 push_gles2_debug

0000000003f70020 g O .bss 0000000000000070 _ZN9gamescope12vblank_debugE
0000000003f72e0a g O .bss 0000000000000001 __odr_asan.cv_drm_debug_disable_explicit_sync
0000000003f72e0e g O .bss 0000000000000001 __odr_asan.cv_drm_debug_disable_degamma_tf
0000000003f729a0 g O .bss 0000000000000070 cv_drm_debug_disable_explicit_sync
0000000003f72e0f g O .bss 0000000000000001 __odr_asan.cv_drm_debug_disable_shaper_and_3dlut
0000000001a9c950 g F .text 0000000000000395 _Z33vulkan_create_debug_blank_texturev
0000000003f72e0c g O .bss 0000000000000001 __odr_asan.cv_drm_debug_disable_output_tf
0000000003f72ae0 g O .bss 0000000000000070 cv_drm_debug_disable_output_tf
0000000003f72e0d g O .bss 0000000000000001 __odr_asan.cv_drm_debug_disable_regamma_tf
0000000002241c20 g F .text 00000000000000af pop_gles2_debug
0000000003f70100 g O .bss 0000000000000001 __odr_asan._ZN9gamescope12vblank_debugE
0000000003f72cc0 g O .bss 0000000000000070 cv_drm_debug_disable_shaper_and_3dlut
0000000003f72c20 g O .bss 0000000000000070 cv_drm_debug_disable_degamma_tf
0000000003f72b80 g O .bss 0000000000000070 cv_drm_debug_disable_regamma_tf
0000000001b3a600 g F .text 00000000000001cd _ZN8LogScope6debugfEPKcz
0000000003f72a40 g O .bss 0000000000000070 cv_drm_debug_disable_blend_tf
0000000003f72e0b g O .bss 0000000000000001 __odr_asan.cv_drm_debug_disable_blend_tf

@kisak-valve
Copy link
Member

Hello @sharkautarch, @repomansez, I'd appreciate if you two stopped creating reply chains of consecutive comments. It adds literal pages of redundant text for no benefit.

@KyunLFA
Copy link
Author

KyunLFA commented May 8, 2024

@sharkautarch That workaround fixed it for me, thanks! Will apply to my fork.

@KyunLFA
Copy link
Author

KyunLFA commented May 8, 2024

Oh wow, that way of checking for xwayland vs wayland was also the fix for the bad variant access when using the wine native wayland driver on embedded!! Still various other bugs, but understanding the steamcompmgr code better like that will help me a ton (in hopes of) getting the Wine wayland.drv plumbed into (my fork of) Gamescope for embedded mode, as nested is already working fine. Tysm @sharkautarch !! Maybe submit a PR for your fix?

@sharkautarch
Copy link

Tysm @sharkautarch !! Maybe submit a PR for your fix?

Sure thing!

@MarijnS95
Copy link

Running into the above backtrace down from determine_and_apply_focus() as well whenever starting an external Wayland application inside gamescope (via WAYLAND_DISPLAY=gamescope-0 myapp). After either applying the linked PR or reverting the offending commit 10aad9c (and 2d70c9c first because of conflicts) on top of 312e25b, the app starts in gamescope again.

However a different bad_variant_access via paint_all -> MouseCursor::paint shows up as soon as the cursor is moved:

(gdb) bt
#0  0x00007f8e800c5e44 in ??? () at /usr/lib/libc.so.6
#1  0x00007f8e8006da30 in raise () at /usr/lib/libc.so.6
#2  0x00007f8e800554c3 in abort () at /usr/lib/libc.so.6
#3  0x00007f8e80497b0c in __gnu_cxx::__verbose_terminate_handler ()
    at /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/vterminate.cc:95
#4  0x00007f8e804adf1a in __cxxabiv1::__terminate (handler=<optimized out>)
    at /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:48
#5  0x00007f8e8049750a in std::terminate () at /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:58
#6  0x00007f8e804ae1d6 in __cxxabiv1::__cxa_throw
    (obj=<optimized out>, tinfo=0x557db191e9d0 <typeinfo for std::bad_variant_access>, dest=0x557db16cea80 <std::bad_variant_access::~bad_variant_access()>) at /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/eh_throw.cc:98
#7  0x0000557db16a2054 in std::__throw_bad_variant_access
    (__what=__what@entry=0x557db183ba38 "std::get: wrong index for variant")
    at /usr/include/c++/14.1.1/variant:1349
#8  0x0000557db16a246c in std::__throw_bad_variant_access (__valueless=<optimized out>)
    at /usr/include/c++/14.1.1/variant:1357
#9  0x0000557db16a3b20 in std::get<0ul, steamcompmgr_xwayland_win_t, steamcompmgr_xdg_win_t>
    (__v=std::variant [index 1] = {...}) at /usr/include/c++/14.1.1/variant:1717
#10 std::get<steamcompmgr_xwayland_win_t, steamcompmgr_xwayland_win_t, steamcompmgr_xdg_win_t>
    (__v=std::variant [index 1] = {...}) at /usr/include/c++/14.1.1/variant:1155
#11 steamcompmgr_win_t::xwayland (this=0x557db273fe60) at ../gamescope/src/steamcompmgr_shared.hpp:138
#12 MouseCursor::paint (this=0x7f8e4c1a0460, window=0x557db273fe60, fit=0x0, frameInfo=0x7f8e594cd480)
    at ../gamescope/src/steamcompmgr.cpp:1701
#13 paint_all (async=<optimized out>) at ../gamescope/src/steamcompmgr.cpp:2287
#14 0x0000557db17037be in steamcompmgr_main (argc=<optimized out>, argv=<optimized out>)
    at ../gamescope/src/steamcompmgr.cpp:7554
#15 0x0000557db1704e3f in steamCompMgrThreadRun (argc=8, argv=0x7ffd28aeec98) at ../gamescope/src/main.cpp:933
#16 0x00007f8e804e0c84 in std::execute_native_thread_routine (__p=0x557db28e0880)
    at /usr/src/debug/gcc/gcc/libstdc++-v3/src/c++11/thread.cc:104
#17 0x00007f8e800c3ded in ??? () at /usr/lib/libc.so.6
#18 0x00007f8e801470dc in ??? () at /usr/lib/libc.so.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants