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

Sanitize Heap::handle(_mut) functions #404

Merged
merged 3 commits into from Mar 23, 2018

Conversation

@Xanewok
Copy link
Contributor

Xanewok commented Mar 23, 2018

Fixes #351.

Also marked Heap::handle as unsafe, hopefully the explanation in the code is concise/good enough.

r? @jdm


This change is Reviewable

Xanewok added 2 commits Mar 23, 2018
Strangely enough, Servo doesn't use it anymore.
Cargo.toml Outdated
@@ -2,7 +2,7 @@
name = "mozjs"
description = "Rust bindings to the Mozilla SpiderMonkey JavaScript engine."
repository = "https://github.com/servo/rust-mozjs"
version = "0.3.2"
version = "0.3.3"

This comment has been minimized.

@Eijebong

Eijebong Mar 23, 2018

Member

This is a breaking change, right ? Should probably be 0.4.0

This comment has been minimized.

@Xanewok

Xanewok Mar 23, 2018

Author Contributor

Yeah, I admit I wanted to cheat a little here :( Wanted to avoid the constant churn with bumping the minor versions, but that should be 0.4, you're right!

This comment has been minimized.

@Xanewok Xanewok force-pushed the Xanewok:remove-heap-handle-mut branch from 14ae181 to 55ae6f5 Mar 23, 2018
Thanks to always vigilant @Eijebong =)
@Xanewok Xanewok force-pushed the Xanewok:remove-heap-handle-mut branch from 55ae6f5 to 8401624 Mar 23, 2018
@Xanewok Xanewok changed the title Remove heap handle mut Sanitize Heap::handle(_mut) functions Mar 23, 2018
@Xanewok Xanewok mentioned this pull request Mar 23, 2018
3 of 5 tasks complete
@jdm
jdm approved these changes Mar 23, 2018
@jdm
Copy link
Member

jdm commented Mar 23, 2018

@bors-servo r+
Hooray for getting rid of footguns!

@bors-servo
Copy link
Contributor

bors-servo commented Mar 23, 2018

📌 Commit 8401624 has been approved by jdm

bors-servo added a commit that referenced this pull request Mar 23, 2018
Sanitize Heap::handle(_mut) functions

Fixes #351.

Also marked `Heap::handle` as `unsafe`, hopefully the explanation in the code is concise/good enough.

r? @jdm

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-mozjs/404)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Mar 23, 2018

Testing commit 8401624 with merge 8fe9be3...

@bors-servo
Copy link
Contributor

bors-servo commented Mar 23, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: jdm
Pushing 8fe9be3 to master...

@bors-servo bors-servo merged commit 8401624 into servo:master Mar 23, 2018
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
bors-servo added a commit to servo/servo that referenced this pull request Mar 23, 2018
Sanitize Heap::handle(_mut) functions

<!-- Please describe your changes on the following line: -->
Complementary to servo/rust-mozjs#404.

Removing `Heap::handle_mut` didn't warrant any changes on Servo side, and so the changes here are only to fix compilation with `Heap::handle` being now marked as `unsafe`.

The main idea is that we can't hand out handles to heap values themselves, since they're not guaranteed to be rooted, but it's safe to do when we are - hence why the safe impl on `RootedTraceableBox<Heap<T>>` and why it's safe to use inside structs that hold a Heap and are `#[must_root]`.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because the compiler forces correctness here.

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20399)
<!-- Reviewable:end -->
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Mar 23, 2018
…ewok:remove-heap-handle-mut); r=jdm

<!-- Please describe your changes on the following line: -->
Complementary to servo/rust-mozjs#404.

Removing `Heap::handle_mut` didn't warrant any changes on Servo side, and so the changes here are only to fix compilation with `Heap::handle` being now marked as `unsafe`.

The main idea is that we can't hand out handles to heap values themselves, since they're not guaranteed to be rooted, but it's safe to do when we are - hence why the safe impl on `RootedTraceableBox<Heap<T>>` and why it's safe to use inside structs that hold a Heap and are `#[must_root]`.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because the compiler forces correctness here.

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: 18ef5874dd3e11551e2f9503746540847eeb974c

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 51f863c54f4fa1d159691fea3ae5b9ff76e004b9
@Xanewok Xanewok deleted the Xanewok:remove-heap-handle-mut branch Mar 23, 2018
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 2, 2019
…ewok:remove-heap-handle-mut); r=jdm

<!-- Please describe your changes on the following line: -->
Complementary to servo/rust-mozjs#404.

Removing `Heap::handle_mut` didn't warrant any changes on Servo side, and so the changes here are only to fix compilation with `Heap::handle` being now marked as `unsafe`.

The main idea is that we can't hand out handles to heap values themselves, since they're not guaranteed to be rooted, but it's safe to do when we are - hence why the safe impl on `RootedTraceableBox<Heap<T>>` and why it's safe to use inside structs that hold a Heap and are `#[must_root]`.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because the compiler forces correctness here.

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: 18ef5874dd3e11551e2f9503746540847eeb974c

UltraBlame original commit: bc04d65246fc16699035c97b2b6aeb94d7df0b08
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 2, 2019
…ewok:remove-heap-handle-mut); r=jdm

<!-- Please describe your changes on the following line: -->
Complementary to servo/rust-mozjs#404.

Removing `Heap::handle_mut` didn't warrant any changes on Servo side, and so the changes here are only to fix compilation with `Heap::handle` being now marked as `unsafe`.

The main idea is that we can't hand out handles to heap values themselves, since they're not guaranteed to be rooted, but it's safe to do when we are - hence why the safe impl on `RootedTraceableBox<Heap<T>>` and why it's safe to use inside structs that hold a Heap and are `#[must_root]`.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because the compiler forces correctness here.

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: 18ef5874dd3e11551e2f9503746540847eeb974c

UltraBlame original commit: bc04d65246fc16699035c97b2b6aeb94d7df0b08
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 2, 2019
…ewok:remove-heap-handle-mut); r=jdm

<!-- Please describe your changes on the following line: -->
Complementary to servo/rust-mozjs#404.

Removing `Heap::handle_mut` didn't warrant any changes on Servo side, and so the changes here are only to fix compilation with `Heap::handle` being now marked as `unsafe`.

The main idea is that we can't hand out handles to heap values themselves, since they're not guaranteed to be rooted, but it's safe to do when we are - hence why the safe impl on `RootedTraceableBox<Heap<T>>` and why it's safe to use inside structs that hold a Heap and are `#[must_root]`.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because the compiler forces correctness here.

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: 18ef5874dd3e11551e2f9503746540847eeb974c

UltraBlame original commit: bc04d65246fc16699035c97b2b6aeb94d7df0b08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.