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

Turning off a display with views will crash wayfire [*Critial BUG*] #2201

Closed
killown opened this issue Mar 12, 2024 · 15 comments · Fixed by #2197
Closed

Turning off a display with views will crash wayfire [*Critial BUG*] #2201

killown opened this issue Mar 12, 2024 · 15 comments · Fixed by #2197
Labels

Comments

@killown
Copy link
Contributor

killown commented Mar 12, 2024

Steps to reproduce: Turn off the ouput through monitor power button and power on again

plugins enabled: stipc autostart command foreign-toplevel gtk-shell idle ipc ipc-rules oswitch resize shortcuts-inhibit window-rules wm-actions workspace-names xdg-activation move focus-change wsets wayfire-shell grid winzoom switcher force-fullscreen fast-switcher view-shot expo alpha vswipe vswitch place cube blur invert mag zoom wobbly follow-focus scale

tested with multi monitor setup

AddressSanitizer:DEADLYSIGNAL
=================================================================
==156737==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000490 (pc 0x7acc62f3c9d7 bp 0x7ffc6c894690 sp 0x7ffc6c893d60 T0)
==156737==The signal is caused by a READ memory access.
==156737==Hint: address points to the zero page.
    #0 0x7acc62f3c9d7 in std::_Rb_tree<nonstd::observer_ptr<wf::toplevel_view_interface_t>, std::pair<nonstd::observer_ptr<wf::toplevel_view_interface_t> const, view_scale_data>, std::_Select1st<std::pair<nonstd::observer_ptr<wf::toplevel_view_interface_t> const, view_scale_data> >, std::less<nonstd::observer_ptr<wf::toplevel_view_interface_t> >, std::allocator<std::pair<nonstd::observer_ptr<wf::toplevel_view_interface_t> const, view_scale_data> > >::_M_begin() const /usr/include/c++/13.2.1/bits/stl_tree.h:747
    #1 0x7acc62f3c9d7 in std::_Rb_tree<nonstd::observer_ptr<wf::toplevel_view_interface_t>, std::pair<nonstd::observer_ptr<wf::toplevel_view_interface_t> const, view_scale_data>, std::_Select1st<std::pair<nonstd::observer_ptr<wf::toplevel_view_interface_t> const, view_scale_data> >, std::less<nonstd::observer_ptr<wf::toplevel_view_interface_t> >, std::allocator<std::pair<nonstd::observer_ptr<wf::toplevel_view_interface_t> const, view_scale_data> > >::find(nonstd::observer_ptr<wf::toplevel_view_interface_t> const&) const /usr/include/c++/13.2.1/bits/stl_tree.h:2545
    #2 0x7acc62f3c9d7 in std::map<nonstd::observer_ptr<wf::toplevel_view_interface_t>, view_scale_data, std::less<nonstd::observer_ptr<wf::toplevel_view_interface_t> >, std::allocator<std::pair<nonstd::observer_ptr<wf::toplevel_view_interface_t> const, view_scale_data> > >::count(nonstd::observer_ptr<wf::toplevel_view_interface_t> const&) const /usr/include/c++/13.2.1/bits/stl_map.h:1266
    #3 0x7acc62f3c9d7 in wayfire_scale::handle_view_disappeared(nonstd::observer_ptr<wf::toplevel_view_interface_t>) ../plugins/scale/scale.cpp:1114
    #4 0x7acc62f81afa in wayfire_scale_global::on_view_set_output::{lambda(wf::view_set_output_signal*)#1}::operator()(wf::view_set_output_signal*) const ../plugins/scale/scale.cpp:1513
    #5 0x7acc62f81afa in void std::__invoke_impl<void, wayfire_scale_global::on_view_set_output::{lambda(wf::view_set_output_signal*)#1}&, wf::view_set_output_signal*>(std::__invoke_other, wayfire_scale_global::on_view_set_output::{lambda(wf::view_set_output_signal*)#1}&, wf::view_set_output_signal*&&) /usr/include/c++/13.2.1/bits/invoke.h:61
    #6 0x7acc62f81afa in std::enable_if<is_invocable_r_v<void, wayfire_scale_global::on_view_set_output::{lambda(wf::view_set_output_signal*)#1}&, wf::view_set_output_signal*>, void>::type std::__invoke_r<void, wayfire_scale_global::on_view_set_output::{lambda(wf::view_set_output_signal*)#1}&, wf::view_set_output_signal*>(wayfire_scale_global::on_view_set_output::{lambda(wf::view_set_output_signal*)#1}&, wf::view_set_output_signal*&&) /usr/include/c++/13.2.1/bits/invoke.h:111
    #7 0x7acc62f81afa in std::_Function_handler<void (wf::view_set_output_signal*), wayfire_scale_global::on_view_set_output::{lambda(wf::view_set_output_signal*)#1}>::_M_invoke(std::_Any_data const&, wf::view_set_output_signal*&&) /usr/include/c++/13.2.1/bits/std_function.h:290
    #8 0x63211ea6db3e in std::function<void (void*)>::operator()(void*) const /usr/include/c++/13.2.1/bits/std_function.h:591
    #9 0x63211ea6db3e in wf::signal::connection_t<wf::view_set_output_signal>::emit(wf::view_set_output_signal*) ../src/api/wayfire/signal-provider.hpp:107
    #10 0x63211ea6db3e in wf::signal::provider_t::emit<wf::view_set_output_signal>(wf::view_set_output_signal*)::{lambda(wf::signal::connection_base_t*)#1}::operator()(wf::signal::connection_base_t*) const ../src/api/wayfire/signal-provider.hpp:163
    #11 0x63211ea6db3e in void std::__invoke_impl<void, wf::signal::provider_t::emit<wf::view_set_output_signal>(wf::view_set_output_signal*)::{lambda(wf::signal::connection_base_t*)#1}&, wf::signal::connection_base_t*&>(std::__invoke_other, wf::signal::provider_t::emit<wf::view_set_output_signal>(wf::view_set_output_signal*)::{lambda(wf::signal::connection_base_t*)#1}&, wf::signal::connection_base_t*&) /usr/include/c++/13.2.1/bits/invoke.h:61
    #12 0x63211ea6db3e in std::enable_if<is_invocable_r_v<void, wf::signal::provider_t::emit<wf::view_set_output_signal>(wf::view_set_output_signal*)::{lambda(wf::signal::connection_base_t*)#1}&, wf::signal::connection_base_t*&>, void>::type std::__invoke_r<void, wf::signal::provider_t::emit<wf::view_set_output_signal>(wf::view_set_output_signal*)::{lambda(wf::signal::connection_base_t*)#1}&, wf::signal::connection_base_t*&>(wf::signal::provider_t::emit<wf::view_set_output_signal>(wf::view_set_output_signal*)::{lambda(wf::signal::connection_base_t*)#1}&, wf::signal::connection_base_t*&) /usr/include/c++/13.2.1/bits/invoke.h:111
    #13 0x63211ea6db3e in std::_Function_handler<void (wf::signal::connection_base_t*&), wf::signal::provider_t::emit<wf::view_set_output_signal>(wf::view_set_output_signal*)::{lambda(wf::signal::connection_base_t*)#1}>::_M_invoke(std::_Any_data const&, wf::signal::connection_base_t*&) /usr/include/c++/13.2.1/bits/std_function.h:290
    #14 0x63211e8ec997 in std::function<void (wf::signal::connection_base_t*&)>::operator()(wf::signal::connection_base_t*&) const /usr/include/c++/13.2.1/bits/std_function.h:591
    #15 0x63211e8ec997 in wf::safe_list_t<wf::signal::connection_base_t*>::for_each(std::function<void (wf::signal::connection_base_t*&)>) ../src/api/wayfire/nonstd/safe-list.hpp:78
    #16 0x63211ea776a1 in void wf::signal::provider_t::emit<wf::view_set_output_signal>(wf::view_set_output_signal*) ../src/api/wayfire/signal-provider.hpp:159
    #17 0x63211ea776a1 in wf::view_interface_t::set_output(wf::output_t*) ../src/view/view.cpp:51
    #18 0x63211ea77e45 in wf::toplevel_view_interface_t::set_output(wf::output_t*) ../src/view/toplevel-view.cpp:183
    #19 0x63211ebb26c0 in wf::workspace_set_t::impl::add_view(nonstd::observer_ptr<wf::toplevel_view_interface_t>) ../src/output/workspace-impl.cpp:399
    #20 0x63211e9930f8 in wf::workspace_set_t::add_view(nonstd::observer_ptr<wf::toplevel_view_interface_t>) ../src/output/workspace-impl.cpp:695
    #21 0x63211e9930f8 in wf::move_view_to_output(nonstd::observer_ptr<wf::toplevel_view_interface_t>, wf::output_t*, bool) ../src/core/core.cpp:490
    #22 0x63211e8f7267 in wf::transfer_views(wf::output_t*, wf::output_t*) ../src/core/output-layout.cpp:155
    #23 0x63211e8fd2b5 in wf::output_layout_output_t::destroy_wayfire_output() ../src/core/output-layout.cpp:536
    #24 0x63211e912b1a in wf::output_layout_output_t::apply_state(wf::output_state_t const&) ../src/core/output-layout.cpp:874
    #25 0x63211e916828 in wf::output_layout_t::impl::apply_configuration(std::map<wlr_output*, wf::output_state_t, std::less<wlr_output*>, std::allocator<std::pair<wlr_output* const, wf::output_state_t> > > const&) ../src/core/output-layout.cpp:1443
    #26 0x63211e91815e in wf::output_layout_t::impl::remove_output(wlr_output*) ../src/core/output-layout.cpp:1182
    #27 0x63211e8d0339 in std::function<void (void*)>::operator()(void*) const /usr/include/c++/13.2.1/bits/std_function.h:591
    #28 0x63211e8d0339 in wf::wl_listener_wrapper::emit(void*) ../src/wl-listener-wrapper.tpp:57
    #29 0x63211e8d0339 in handle_wrapped_listener ../src/wl-listener-wrapper.tpp:10
    #30 0x7acc7d57f01d in wl_signal_emit_mutable (/usr/lib/libwayland-server.so.0+0xa01d) (BuildId: d943a6a6069d1b5293dad7c842d26ce407ebdd19)
    #31 0x7acc7cb53a23 in wlr_output_destroy ../subprojects/wlroots/types/output/output.c:453
    #32 0x7acc7cb53a23 in wlr_output_destroy ../subprojects/wlroots/types/output/output.c:448
    #33 0x7acc7cb18543 in disconnect_drm_connector ../subprojects/wlroots/backend/drm/drm.c:1788
    #34 0x7acc7cb18543 in scan_drm_connectors ../subprojects/wlroots/backend/drm/drm.c:1632
    #35 0x7acc7d57f01d in wl_signal_emit_mutable (/usr/lib/libwayland-server.so.0+0xa01d) (BuildId: d943a6a6069d1b5293dad7c842d26ce407ebdd19)
    #36 0x7acc7cb017a6 in handle_udev_event ../subprojects/wlroots/backend/session/session.c:213
    #37 0x7acc7d580ae1 in wl_event_loop_dispatch (/usr/lib/libwayland-server.so.0+0xbae1) (BuildId: d943a6a6069d1b5293dad7c842d26ce407ebdd19)
    #38 0x7acc7d5812d6 in wl_display_run (/usr/lib/libwayland-server.so.0+0xc2d6) (BuildId: d943a6a6069d1b5293dad7c842d26ce407ebdd19)
    #39 0x63211e8caae0 in main ../src/main.cpp:422
    #40 0x7acc7c357ccf  (/usr/lib/libc.so.6+0x25ccf) (BuildId: c0caa0b7709d3369ee575fcd7d7d0b0fc48733af)
    #41 0x7acc7c357d89 in __libc_start_main (/usr/lib/libc.so.6+0x25d89) (BuildId: c0caa0b7709d3369ee575fcd7d7d0b0fc48733af)
    #42 0x63211e8cfce4 in _start (/usr/bin/wayfire+0xf6ce4) (BuildId: 3e6c3dcffc60b887d9a6c0237f9a184a8df73179)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /usr/include/c++/13.2.1/bits/stl_tree.h:747 in std::_Rb_tree<nonstd::observer_ptr<wf::toplevel_view_interface_t>, std::pair<nonstd::observer_ptr<wf::toplevel_view_interface_t> const, view_scale_data>, std::_Select1st<std::pair<nonstd::observer_ptr<wf::toplevel_view_interface_t> const, view_scale_data> >, std::less<nonstd::observer_ptr<wf::toplevel_view_interface_t> >, std::allocator<std::pair<nonstd::observer_ptr<wf::toplevel_view_interface_t> const, view_scale_data> > >::_M_begin() const
==156737==ABORTING
(EE) failed to read Wayland events: Broken pipe
@killown killown added the bug label Mar 12, 2024
@mark-herbert42
Copy link

Tried to simulate that - connected the additional monitor, opened filemanager window - it opened on main screen. Then dragged it to the external monitor. and - the moment I dropped it there - got a crash. Repeated several times - same result.

When I grab the window and drag it to the right (where my additional monitor is connected) - all ok. Until I release the mouse button to drop the window.

@killown
Copy link
Contributor Author

killown commented Mar 12, 2024

Tried to simulate that - connected the additional monitor, opened filemanager window - it opened on main screen. Then dragged it to the external monitor. and - the moment I dropped it there - got a crash. Repeated several times - same result.

When I grab the window and drag it to the right (where my additional monitor is connected) - all ok. Until I release the mouse button to drop the window.

looks like a different issue, can you enable the debug to report?

@mark-herbert42
Copy link

wayfire.log.gz

backtrace.txt

Here is wayfire log from buildtype=debug + gdb backtrace from coredump

@killown
Copy link
Contributor Author

killown commented Mar 12, 2024

wayfire.log.gz

backtrace.txt

Here is wayfire log from buildtype=debug + gdb backtrace from coredump

this is a different issue, would be nice if you had -Db_sanitize=address --buildtype=debug and the open a new issue

@mark-herbert42
Copy link

Seems that my issue was becaiuse I've applied PR #2197 Reversed it and it is fine.

@ammen99
Copy link
Member

ammen99 commented Mar 12, 2024

@mark-herbert42 Are you sure this is because of #2197? I don't see much there which could even cause the bug you mentioned. It is probably the previous PR, #2165

@mark-herbert42
Copy link

No, it is exactly 2197. Just tried again - current git version works fine. Apply 2197 on top of current git - crash.

@ammen99
Copy link
Member

ammen99 commented Mar 12, 2024

No, it is exactly 2197. Just tried again - current git version works fine. Apply 2197 on top of current git - crash.

Oh, I think the problem is that I mistakenly have a print_trace() call where it shouldn't be. I've updated the PR, that should probably fix your problem.

@ammen99
Copy link
Member

ammen99 commented Mar 12, 2024

I just pushed a fix for this on my PR #2197

ammen99 added a commit that referenced this issue Mar 12, 2024
ammen99 added a commit that referenced this issue Mar 12, 2024
@killown
Copy link
Contributor Author

killown commented Mar 13, 2024

I just pushed a fix for this on my PR #2197

Thanks for the fix, solved!

@mark-herbert42
Copy link

It works now - no crash, and if I disconnect monitor windows safely return to the main laptop screen.
The only strange point - I have weird laptop resoution of 2944 pixels (thanks, Lenovo) so monitor that matches my laptop does not exist. Monitor has 2560, but sometimes get activated as 1920.

Then I open small fm (mate caja) window and drag it there to the monitor. Window looks bigger - it remains same size in pixels, bit monitor has less pixels that makes window take bigger part of the screen. When I disconnect monitor - window returns to the main screen - but it becomes big. Instead of preserving size in pixels (as happen when I move the window there) - it presereves window to screen relative size.

@ammen99
Copy link
Member

ammen99 commented Mar 13, 2024

@mark-herbert42 Do you have different scale configured for the outputs? The logical size is preserved across monitors - and if you move from 1x to 2x scale monitor, the actual size will therefore double.

@mark-herbert42
Copy link

No - I have the same scale 1.0 on both of them. It looks like the system is recalculating something based on resolution of the monitor, not DPI scale. When I set up both monitors to run 1920 resolution this does not happen - windos restores back same size it was dropped. But in my live scenario - 2944 pixel wide laptop panel and 1920 external monitor - 2 cycles open small window - drop it to external monitor - disconnect monitor - ends up in window taking the full screen.

Actually this happen when I disconnect monitor. If i just move window between monitors - nothing happens, window remains the same. But when I do dsiconnect monitor - that means the output is not there anymore. So what will be the scale for non-existing monitor then?

@mark-herbert42
Copy link

Also I've noticed that disconnecting monitor crashes wf-background. Not immediately - but it will foe sure crash. I've set the cycle timeout - so it happens most likely on attempt to change background when time comes, not by the fact of monitor disconnect.

@ammen99
Copy link
Member

ammen99 commented Mar 13, 2024

Also I've noticed that disconnecting monitor crashes wf-background. Not immediately - but it will foe sure crash. I've set the cycle timeout - so it happens most likely on attempt to change background when time comes, not by the fact of monitor disconnect.

Sounds like a completely unrelated issue.

Actually this happen when I disconnect monitor. If i just move window between monitors - nothing happens, window remains the same. But when I do dsiconnect monitor - that means the output is not there anymore. So what will be the scale for non-existing monitor then?

Thanks, I think with this hint I can see what is going on. See #2211

ammen99 added a commit that referenced this issue Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants