Skip to content

Remove DerefMut impl for JS::MutableHandle #574

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
Mar 26, 2025

Conversation

gmorenz
Copy link
Contributor

@gmorenz gmorenz commented Mar 26, 2025

Like with #572 and #573 this impl allows for improper aliasing with the GC. With this type it also allows for outright use after frees, since JS::MutableHandle, like a raw pointer, has no lifetime attached to it. Eventually that's a justification for removing the Deref impl as well, but once thing at a time.

There's only one use of this in servo, which is removed in the accompanying PR: servo/servo#36161

Like with #572 and #573 I added an unsafe as_mut method, though it is unused locally this time as well as in servo. It feels like a reasonable escape hatch to share even if it isn't currently used.

Part of #569, and can be merged entirely independently from #572 and #573.

@gmorenz gmorenz force-pushed the js_mutable_handle_deref_mut branch from 727956e to 1658f77 Compare March 26, 2025 15:13
@@ -119,6 +112,13 @@ impl<T> JS::MutableHandle<T> {
{
unsafe { *self.ptr = v }
}

/// The returned pointer is aliased by a pointer that the GC will read
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added a task to the tracking issue to update this comment if we don't convert the GC to only write via interior mutability.

@sagudev sagudev added this pull request to the merge queue Mar 26, 2025
Merged via the queue into servo:main with commit db131fc Mar 26, 2025
27 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