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

inputmgr ensure we dont divide by zero #6713

Merged
merged 1 commit into from
Jun 30, 2024
Merged

Conversation

gulafaran
Copy link
Contributor

some weird combination of scrolling/nesting hyprland and closing a window i managed to divide by zero here, reported by ubsan. add a check to ensure we dont hit UB.

report from ubsan when it triggered.

/home/tom/dev/Hyprland/src/managers/input/InputManager.cpp:802:73: runtime error: -nan is outside the range of representable values of type 'int'
    #0 0x55555a764b94 in CInputManager::onMouseWheel(IPointer::SAxisEvent) /home/tom/dev/Hyprland/src/managers/input/InputManager.cpp:802:73
    #1 0x55555a60222e in CPointerManager::attachPointer(Hyprutils::Memory::CSharedPointer<IPointer>)::$_4::operator()(std::any) const /home/tom/dev/Hyprland/src/managers/PointerManager.cpp:846:26
    #2 0x55555a602011 in void std::__invoke_impl<void, CPointerManager::attachPointer(Hyprutils::Memory::CSharedPointer<IPointer>)::$_4&, std::any>(std::__invoke_other, CPointerManager::attachPointer(Hyprutils::Memory::CSharedPointer<IPointer>)::$_4&, std::any&&) /usr/lib/gcc/x86_64-pc-linux-gnu/14/include/g++-v14/bits/invoke.h:61:14
    #3 0x55555a601dec in std::enable_if<is_invocable_r_v<void, CPointerManager::attachPointer(Hyprutils::Memory::CSharedPointer<IPointer>)::$_4&, std::any>, void>::type std::__invoke_r<void, CPointerManager::attachPointer(Hyprutils::Memory::CSharedPointer<IPointer>)::$_4&, std::any>(CPointerManager::attachPointer(Hyprutils::Memory::CSharedPointer<IPointer>)::$_4&, std::any&&) /usr/lib/gcc/x86_64-pc-linux-gnu/14/include/g++-v14/bits/invoke.h:111:2
    #4 0x55555a601a38 in std::_Function_handler<void (std::any), CPointerManager::attachPointer(Hyprutils::Memory::CSharedPointer<IPointer>)::$_4>::_M_invoke(std::_Any_data const&, std::any&&) /usr/lib/gcc/x86_64-pc-linux-gnu/14/include/g++-v14/bits/std_function.h:290:9
    #5 0x7ffff74c600a in Hyprutils::Signal::CSignalListener::emit(std::any) (/usr/lib64/libhyprutils.so.0+0x600a)
    #6 0x7ffff74c65a3 in Hyprutils::Signal::CSignal::emit(std::any) (/usr/lib64/libhyprutils.so.0+0x65a3)

ubsan hints at the line below, but the "-nan" is outside of range seems to me to suggest its a division by zero.
in any rate safeguard against it anyways.

some weird combination of scrolling/nesting hyprland and closing a
window i managed to divide by zero here, reported by ubsan. add a check
to ensure we dont hit UB.
Copy link
Member

@vaxerski vaxerski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks :)

@vaxerski vaxerski merged commit 8ff9410 into hyprwm:main Jun 30, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants