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

MutableHandle are clonable breaking safety provided by &mut #520

Open
sagudev opened this issue Nov 2, 2024 · 2 comments
Open

MutableHandle are clonable breaking safety provided by &mut #520

sagudev opened this issue Nov 2, 2024 · 2 comments

Comments

@sagudev
Copy link
Member

sagudev commented Nov 2, 2024

mut is required for https://doc.servo.org/mozjs/gc/root/struct.MutableHandle.html#tymethod.set, but this is still weird as MutableHandle is clonable so &mut does not help a lot with safety.

Originally posted by @sagudev in servo/servo#34087 (comment)

When cloning MutableHandle we still have underlying pointer point to same location, so we can have two &mut that points to same location.

@sagudev
Copy link
Member Author

sagudev commented Nov 2, 2024

I think the proper solution would be to not impl Clone/Copy for *Handle or at least mark it as unsafe.

@sagudev
Copy link
Member Author

sagudev commented Nov 2, 2024

I think the first action point would be to remove all mozjs::rust::wrappers usages, then we can remove clone,copy in followup.

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

No branches or pull requests

1 participant