Skip to content

Make FlowRef a newtype - #14053

Merged
bors-servo merged 1 commit into
servo:masterfrom
notriddle:flow_ref_unsafe
Nov 4, 2016
Merged

bors-servo merged 1 commit into
servo:masterfrom
notriddle:flow_ref_unsafe

Conversation

@notriddle

@notriddle notriddle commented Nov 3, 2016 •

Copy link
Copy Markdown
Contributor

This creates a sharp distinction between Arc<Flow>s, which may be
owned by anyone, and FlowRefs, which may only be owned by the
traversal code. By checking the reference count, we ensure that a Flow
cannot be pointed to by Arcs and FlowRefs simultaneously.

This is not a complete fix for #6503, though it is a necessary start
(enforcing the no-aliasing rule of FlowRef::deref_mut will require far
more work).


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix Fragmentation could be non-memory-safe #14014 (github issue number if applicable).
  • These changes do not require tests because the existing tests, plus the added assertions, should be sufficient

This change is Reviewable

@highfive

highfive commented Nov 3, 2016

Copy link
Copy Markdown

Heads up! This PR modifies the following files:

  • @emilio: components/layout/flow_ref.rs, components/layout/construct.rs, components/layout/fragment.rs, components/layout/display_list_builder.rs, components/layout/Cargo.lock, components/layout/flow_list.rs, components/layout/block.rs, components/layout/inline.rs, components/layout/flow.rs, components/layout/multicol.rs

@highfive

highfive commented Nov 3, 2016

Copy link
Copy Markdown

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!
  • These commits modify layout code, but no tests are modified. Please consider adding a test!

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Nov 3, 2016
@notriddle

Copy link
Copy Markdown
Contributor Author

@bors-servo try

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Trying commit 89eda59 with merge 064760c...

bors-servo pushed a commit that referenced this pull request Nov 3, 2016
Make `FlowRef` a newtype

This creates a sharp distinction between `Arc<Flow>`s, which may be
owned by anyone, and `FlowRef`s, which may only be owned by the
traversal code. By checking the reference count, we ensure that a `Flow`
cannot be pointed to by `Arc`s and `FlowRef`s simultaneously.

This is not a complete fix for #6503, though it is a necessary start
(enforcing the no-aliasing rule of `FlowRef::deref_mut` will require far
more work).

---

- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #14014 (github issue number if applicable).
- [X] These changes do not require tests because the existing tests, plus the added assertions, should be sufficient

<!-- 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/14053)
<!-- Reviewable:end -->
@notriddle

Copy link
Copy Markdown
Contributor Author

@bors-servo try

I committed a logfile. ☹️

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Trying commit 207b5d2 with merge 2b8a488...

bors-servo pushed a commit that referenced this pull request Nov 3, 2016
Make `FlowRef` a newtype

This creates a sharp distinction between `Arc<Flow>`s, which may be
owned by anyone, and `FlowRef`s, which may only be owned by the
traversal code. By checking the reference count, we ensure that a `Flow`
cannot be pointed to by `Arc`s and `FlowRef`s simultaneously.

This is not a complete fix for #6503, though it is a necessary start
(enforcing the no-aliasing rule of `FlowRef::deref_mut` will require far
more work).

---

- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #14014 (github issue number if applicable).
- [X] These changes do not require tests because the existing tests, plus the added assertions, should be sufficient

<!-- 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/14053)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
Contributor

💥 Test timed out

@jdm

jdm commented Nov 4, 2016

Copy link
Copy Markdown
Member

@bors-servo: retry

@notriddle

Copy link
Copy Markdown
Contributor Author

@bors-servo clean try

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Trying commit 207b5d2 with merge 89c7997...

bors-servo pushed a commit that referenced this pull request Nov 4, 2016
Make `FlowRef` a newtype

This creates a sharp distinction between `Arc<Flow>`s, which may be
owned by anyone, and `FlowRef`s, which may only be owned by the
traversal code. By checking the reference count, we ensure that a `Flow`
cannot be pointed to by `Arc`s and `FlowRef`s simultaneously.

This is not a complete fix for #6503, though it is a necessary start
(enforcing the no-aliasing rule of `FlowRef::deref_mut` will require far
more work).

---

- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #14014 (github issue number if applicable).
- [X] These changes do not require tests because the existing tests, plus the added assertions, should be sufficient

<!-- 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/14053)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - linux-rel-wpt

@notriddle

notriddle commented Nov 4, 2016 •

Copy link
Copy Markdown
Contributor Author

linux-rel-wpt:

linux-rel-css passed

@pcwalton

pcwalton commented Nov 4, 2016

Copy link
Copy Markdown
Contributor

So the idea here is that Arc<Flow> can never be in the tree, so it's safe for layout code to have access to them, while FlowRef represents a flow in the tree, which is forbidden to leak to layout?

If so, I hadn't considered this solution; very clever :)

@notriddle

Copy link
Copy Markdown
Contributor Author

@pcwalton Exactly. And thank you. 😄

@notriddle

Copy link
Copy Markdown
Contributor Author

By the way, all the tests passed. r?

Comment thread components/layout/flow_ref.rs Outdated
}

impl FlowRef {
/// `FlowRef`s can only be made availabe to the traversal code.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

typo: "available"

@pcwalton

pcwalton commented Nov 4, 2016

Copy link
Copy Markdown
Contributor

r=me, squash away

@jdm jdm added S-needs-squash Some (or all) of the commits in the PR should be combined. and removed S-awaiting-review There is new code that needs to be reviewed. labels Nov 4, 2016
This creates a sharp distinction between `Arc<Flow>`s, which may be
owned by anyone, and `FlowRef`s, which may only be owned by the
traversal code. By checking the reference count, we ensure that a `Flow`
cannot be pointed to by `Arc`s and `FlowRef`s simultaneously.

This is not a complete fix for #6503, though it is a necessary start
(enforcing the no-aliasing rule of `FlowRef::deref_mut` will require far
more work).

Fixes #14014
@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Nov 4, 2016
@notriddle

Copy link
Copy Markdown
Contributor Author

@bors-servo r=pcwalton

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 5f320bd has been approved by pcwalton

@highfive highfive assigned pcwalton and unassigned SimonSapin Nov 4, 2016
@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. S-needs-squash Some (or all) of the commits in the PR should be combined. labels Nov 4, 2016
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 5f320bd with merge 2b4a7b0...

bors-servo pushed a commit that referenced this pull request Nov 4, 2016
Make `FlowRef` a newtype

This creates a sharp distinction between `Arc<Flow>`s, which may be
owned by anyone, and `FlowRef`s, which may only be owned by the
traversal code. By checking the reference count, we ensure that a `Flow`
cannot be pointed to by `Arc`s and `FlowRef`s simultaneously.

This is not a complete fix for #6503, though it is a necessary start
(enforcing the no-aliasing rule of `FlowRef::deref_mut` will require far
more work).

---

- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #14014 (github issue number if applicable).
- [X] These changes do not require tests because the existing tests, plus the added assertions, should be sufficient

<!-- 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/14053)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
Contributor

@bors-servo
bors-servo merged commit 5f320bd into servo:master Nov 4, 2016
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Nov 4, 2016
@bors-servo bors-servo mentioned this pull request Nov 4, 2016
4 of 5 tasks
@notriddle
notriddle deleted the flow_ref_unsafe branch November 4, 2016 23:07
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.

Fragmentation could be non-memory-safe

6 participants