servo: Merge #19607 - hashglobe: Dump the requested aligment if out of memory while allocating a table (from BorisChiou:stylo/crash/out_of_memory_alignment); r=emilio
authorBoris Chiou <boris.chiou@gmail.com>
Mon, 01 Jan 2018 21:32:59 -0600
changeset 449313 be2a93f7d4b4768877c1320b6f6acfa21c32bc8d
parent 449312 f73719c150e65186c9341edb7afe0fcda8edb897
child 449314 76019db4698f426b227314575cb795978de78184
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1418806, 1416903
milestone59.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 #19607 - hashglobe: Dump the requested aligment if out of memory while allocating a table (from BorisChiou:stylo/crash/out_of_memory_alignment); r=emilio This is for Bug 1418806 and Bug 1416903. We need not only the requested size but also the requested alignment for debugging. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors Source-Repo: https://github.com/servo/servo Source-Revision: 27a443fbaaf3e19fa3a753f68b20a7a7ccc5d199
servo/components/hashglobe/src/lib.rs
servo/components/hashglobe/src/table.rs
--- a/servo/components/hashglobe/src/lib.rs
+++ b/servo/components/hashglobe/src/lib.rs
@@ -22,35 +22,45 @@ trait Recover<Q: ?Sized> {
     type Key;
 
     fn get(&self, key: &Q) -> Option<&Self::Key>;
     fn take(&mut self, key: &Q) -> Option<Self::Key>;
     fn replace(&mut self, key: Self::Key) -> Option<Self::Key>;
 }
 
 #[derive(Debug)]
+pub struct AllocationInfo {
+    /// The size we are requesting.
+    size: usize,
+    /// The alignment we are requesting.
+    alignment: usize,
+}
+
+#[derive(Debug)]
 pub struct FailedAllocationError {
     reason: &'static str,
-    /// The size we are allocating, if needed.
-    allocation_size: Option<usize>,
+    /// The allocation info we are requesting, if needed.
+    allocation_info: Option<AllocationInfo>,
 }
 
 impl FailedAllocationError {
     #[inline]
     pub fn new(reason: &'static str) -> Self {
-        Self { reason, allocation_size: None }
+        Self { reason, allocation_info: None }
     }
 }
 
 impl error::Error for FailedAllocationError {
     fn description(&self) -> &str {
         self.reason
     }
 }
 
 impl fmt::Display for FailedAllocationError {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        match self.allocation_size {
-            Some(size) => write!(f, "{}, allocation size: {}", self.reason, size),
+        match self.allocation_info {
+            Some(ref info) => {
+                write!(f, "{}, allocation: (size: {}, alignment: {})", self.reason, info.size, info.alignment)
+            },
             None => self.reason.fmt(f),
         }
     }
 }
--- a/servo/components/hashglobe/src/table.rs
+++ b/servo/components/hashglobe/src/table.rs
@@ -773,19 +773,20 @@ impl<K, V> RawTable<K, V> {
             return Err(FailedAllocationError::new("capacity overflow when allocating RawTable"));
         }
 
 
         // FORK NOTE: Uses alloc shim instead of Heap.alloc
         let buffer = alloc(size, alignment);
 
         if buffer.is_null() {
+            use AllocationInfo;
             return Err(FailedAllocationError {
                 reason: "out of memory when allocating RawTable",
-                allocation_size: Some(size),
+                allocation_info: Some(AllocationInfo { size, alignment }),
             });
         }
 
         let hashes = buffer.offset(hash_offset as isize) as *mut HashUint;
 
         Ok(RawTable {
             capacity_mask: capacity.wrapping_sub(1),
             size: 0,