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

[breaking][core-graphics] Enforce Sendness of CGEventTap callback (soundness fix) #725

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

tmandry
Copy link
Contributor

@tmandry tmandry commented Mar 16, 2025

There was an aspect of unsoundness missed in #710. The callback can capture state from the current thread that is not Send, but the tap can be installed on another thread's event loop.

This change fixes the unsoundness while providing a way to safely and conveniently use the API that fits most use cases. CGEventTap::with (unreleased API) was renamed to with_enabled because it actually installs and enables the tap now.

Also make CGEventTap #[must_use] so users of new don't accidentally drop the tap.

This change is currently based on #724 but can be rebased if you want to merge it independently.

tmandry added 3 commits March 15, 2025 22:57
This prevents a failure mode of handling the Result of CGEventTap::new()
but not saving the tap itself.
This was previously unsound.
@tmandry
Copy link
Contributor Author

tmandry commented Mar 16, 2025

cc @wusyong

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.

1 participant