diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2020-01-22 00:06:35 +0000 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2020-02-12 02:43:19 +0100 |
commit | b038924d44cc3d991a227e0a575da8f77a76c231 (patch) | |
tree | db6fc3cbfd3ced4834258eb97863b8c50939d814 /components/style/rule_tree/mod.rs | |
parent | df01cec675b5b0b1918e516d9842cef4e1ae4bbb (diff) | |
download | servo-b038924d44cc3d991a227e0a575da8f77a76c231.tar.gz servo-b038924d44cc3d991a227e0a575da8f77a76c231.zip |
style: Try to collect some more crash information so that we can diagnose this better.
Differential Revision: https://phabricator.services.mozilla.com/D59704
Diffstat (limited to 'components/style/rule_tree/mod.rs')
-rw-r--r-- | components/style/rule_tree/mod.rs | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/components/style/rule_tree/mod.rs b/components/style/rule_tree/mod.rs index fa859d79f06..1dbc17eaf34 100644 --- a/components/style/rule_tree/mod.rs +++ b/components/style/rule_tree/mod.rs @@ -136,6 +136,27 @@ impl StyleSource { let _ = write!(writer, " -> {:?}", self.read(guard).declarations()); } + // This is totally unsafe, should be removed when we figure out the cause of + // bug 1607553. + unsafe fn dump_unchecked<W: Write>(&self, writer: &mut W) { + if let Some(ref rule) = self.0.as_first() { + let rule = rule.read_unchecked(); + let _ = write!(writer, "{:?}", rule.selectors); + } + let _ = write!(writer, " -> {:?}", self.read_unchecked().declarations()); + } + + // This is totally unsafe, should be removed when we figure out the cause of + // bug 1607553. + #[inline] + unsafe fn read_unchecked(&self) -> &PropertyDeclarationBlock { + let block: &Locked<PropertyDeclarationBlock> = match self.0.borrow() { + ArcUnionBorrow::First(ref rule) => &rule.get().read_unchecked().block, + ArcUnionBorrow::Second(ref block) => block.get(), + }; + block.read_unchecked() + } + /// Read the style source guard, and obtain thus read access to the /// underlying property declaration block. #[inline] @@ -1720,7 +1741,23 @@ impl Drop for StrongRuleNode { } if cfg!(debug_assertions) || crate::gecko_bindings::structs::GECKO_IS_NIGHTLY { - assert!(node.children.read().is_empty()); + let children = node.children.read(); + if !children.is_empty() { + let mut crash_str = vec![]; + unsafe { + // Try to unsafely collect some information of this before + // crashing the process. + if let Some(ref s) = node.source { + s.dump_unchecked(&mut crash_str); + crash_str.push(b'\n'); + } + children.each(|child| { + (*child.ptr()).source.as_ref().unwrap().dump_unchecked(&mut crash_str); + crash_str.push(b'\n'); + }); + } + panic!("Children left in the rule tree on drop: {}", String::from_utf8_lossy(&crash_str).trim()); + } } if node.parent.is_none() { |