Skip to content

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

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

Merged
merged 2 commits into from
May 26, 2025

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
Copy link
Contributor Author

tmandry commented Mar 16, 2025

cc @wusyong

tmandry added 2 commits May 26, 2025 15:18
This prevents a failure mode of handling the Result of CGEventTap::new()
but not saving the tap itself.
This was previously unsound.
@jdm jdm enabled auto-merge May 26, 2025 19:18
@jdm jdm added this pull request to the merge queue May 26, 2025
Merged via the queue into servo:main with commit f0882ea May 26, 2025
8 checks passed
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