servo: Merge #16816 - Fix unsafe casting between PersistentLayoutData and PartialPersistentLayoutData (from MortimerGoro:unsafe_layout_data_cast); r=SimonSapin
authorImanol Fernandez <mortimergoro@gmail.com>
Thu, 11 May 2017 14:47:24 -0500
changeset 357863 385067a8df33c105a085db31c52d7a68f519f804
parent 357862 ccd0ac82b8bd099388926c642f03313a2826f023
child 357864 ecfb960dc1097ab0e34b4c83caebc9c88c03c03f
push id42526
push userservo-vcs-sync@mozilla.com
push dateThu, 11 May 2017 21:10:54 +0000
treeherderautoland@385067a8df33 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersSimonSapin
bugs16816, 16647
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
servo: Merge #16816 - Fix unsafe casting between PersistentLayoutData and PartialPersistentLayoutData (from MortimerGoro:unsafe_layout_data_cast); r=SimonSapin <!-- Please describe your changes on the following line: --> PersistentLayoutData and PartialPersistentLayoutData castings in Layout component assume that they have the same base raw address. This is unsafe because field orders is not guaranteed by default, and it's causing some SEGV crashes on Android indeed (https://github.com/servo/servo/issues/16647) Add a C representation to guarantee that the order of the fields and the safe casting. --- <!-- 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 - [x] These changes fix #16647 (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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: c277beab2b9c3294ea69c6088cd0dc3b1665717e
servo/components/layout/data.rs
--- a/servo/components/layout/data.rs
+++ b/servo/components/layout/data.rs
@@ -1,16 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 use construct::ConstructionResult;
 use script_layout_interface::PartialPersistentLayoutData;
 
 /// Data that layout associates with a node.
+#[repr(C)]
 pub struct PersistentLayoutData {
     /// Data accessed by script_layout_interface. This must be first to allow
     /// casting between PersistentLayoutData and PartialPersistentLayoutData.
     pub base: PartialPersistentLayoutData,
 
     /// The current results of flow construction for this node. This is either a
     /// flow or a `ConstructionItem`. See comments in `construct.rs` for more
     /// details.