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

fix a few asan reported leaks on exit of hyprland #5852

Merged
merged 5 commits into from
May 3, 2024

Conversation

gulafaran
Copy link
Contributor

Describe your PR, what does it fix/add?

a few of the leaks are mostly unimportant since the OS will reclaim the memory anways, but it reduces the asan spam if one builds with it atleast.

Is there anything you want to mention? (unchecked code, possible bugs, found problems, breaking compatibility, etc.)

the changes could use some testing and reviewing so i didnt miss anything obvious, perhaps some weird combination of HW and situation will cause some use after free?

asan reports a leak on exit if we dont free the image we created in the
draw function. add a destructor and free images on exit.
there are a few types not being destroyed on exit and causing a leak on
exit in wlroots reported by asan, add those.
add a destructor and call wlr_xcursor_manager_destroy on the manager on
destruction, leak reported by asan.
add missing keymap_unref on creation, and add a destructor and free the
state on exit. leak reported by asan.
free the state on destruction of keyboard, reported as leak by asan
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.

dunno why this is a problem but sure I guess

@vaxerski vaxerski merged commit d5bf153 into hyprwm:main May 3, 2024
10 checks passed
@gulafaran
Copy link
Contributor Author

dunno why this is a problem but sure I guess

i knew i missed something obvious, im on a laptop and went into the closet digging for some dusty old logitech usb keyboard. hottplugging its gonna double free because its not set to nullptr here

diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index 58b5caa3..fb9d2b8a 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -1195,6 +1195,7 @@ void CInputManager::destroyKeyboard(SKeyboard* pKeyboard) {
     pKeyboard->hyprListener_keyboardKey.removeCallback();
 
     xkb_state_unref(pKeyboard->xkbTranslationState);
+    pKeyboard->xkbTranslationState = nullptr;
 
     m_lKeyboards.remove(*pKeyboard);

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

Successfully merging this pull request may close these issues.

2 participants