Skip to content

Commit f457bf6

Browse files
committed
Revert #18668 - Add mprotect diagnostics for HashMap crash.
1 parent e07c6f3 commit f457bf6

File tree

17 files changed

+9
-448
lines changed

17 files changed

+9
-448
lines changed

Cargo.lock

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/hashglobe/src/hash_map.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,12 +1027,6 @@ impl<K, V, S> HashMap<K, V, S>
10271027
self.table.size()
10281028
}
10291029

1030-
/// Access to the raw buffer backing this hashmap.
1031-
pub fn raw_buffer(&self) -> (*const (), usize) {
1032-
assert!(self.raw_capacity() != 0);
1033-
self.table.raw_buffer()
1034-
}
1035-
10361030
/// Returns true if the map contains no elements.
10371031
///
10381032
/// # Examples

components/hashglobe/src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ extern crate heapsize;
1313
pub mod alloc;
1414
pub mod hash_map;
1515
pub mod hash_set;
16-
pub mod protected;
1716
mod shim;
1817
mod table;
1918

@@ -52,6 +51,3 @@ impl fmt::Display for FailedAllocationError {
5251
self.reason.fmt(f)
5352
}
5453
}
55-
56-
// The size of memory pages on this system. Set when initializing geckolib.
57-
pub static SYSTEM_PAGE_SIZE: ::std::sync::atomic::AtomicUsize = ::std::sync::atomic::ATOMIC_USIZE_INIT;

components/hashglobe/src/protected.rs

Lines changed: 0 additions & 235 deletions
This file was deleted.

components/hashglobe/src/table.rs

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ impl<K, V> RawTable<K, V> {
777777

778778

779779
// FORK NOTE: Uses alloc shim instead of Heap.alloc
780-
let buffer = alloc(round_up_to_page_size(size), alignment);
780+
let buffer = alloc(size, alignment);
781781

782782
if buffer.is_null() {
783783

@@ -813,24 +813,6 @@ impl<K, V> RawTable<K, V> {
813813
}
814814
}
815815

816-
/// Access to the raw buffer backing this table.
817-
pub fn raw_buffer(&self) -> (*const (), usize) {
818-
debug_assert!(self.capacity() != 0);
819-
820-
let buffer = self.hashes.ptr() as *const ();
821-
let size = {
822-
let hashes_size = self.capacity() * size_of::<HashUint>();
823-
let pairs_size = self.capacity() * size_of::<(K, V)>();
824-
let (_, _, size, _) = calculate_allocation(hashes_size,
825-
align_of::<HashUint>(),
826-
pairs_size,
827-
align_of::<(K, V)>());
828-
round_up_to_page_size(size)
829-
};
830-
(buffer, size)
831-
}
832-
833-
834816
/// Creates a new raw table from a given capacity. All buckets are
835817
/// initially empty.
836818
pub fn new(capacity: usize) -> Result<RawTable<K, V>, FailedAllocationError> {
@@ -1219,19 +1201,3 @@ impl<K, V> Drop for RawTable<K, V> {
12191201
}
12201202
}
12211203
}
1222-
1223-
// Force all allocations to fill their pages for the duration of the mprotect
1224-
// experiment.
1225-
#[inline]
1226-
fn round_up_to_page_size(size: usize) -> usize {
1227-
let page_size = ::SYSTEM_PAGE_SIZE.load(::std::sync::atomic::Ordering::Relaxed);
1228-
debug_assert!(page_size != 0);
1229-
let mut result = size;
1230-
let remainder = size % page_size;
1231-
if remainder != 0 {
1232-
result += page_size - remainder;
1233-
}
1234-
debug_assert!(result % page_size == 0);
1235-
debug_assert!(result - size < page_size);
1236-
result
1237-
}

components/malloc_size_of/lib.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -339,25 +339,6 @@ impl<K, V, S> MallocSizeOf for hashglobe::hash_map::HashMap<K, V, S>
339339
}
340340
}
341341

342-
impl<K, V, S> MallocShallowSizeOf for hashglobe::protected::ProtectedHashMap<K, V, S>
343-
where K: Eq + Hash,
344-
S: BuildHasher
345-
{
346-
fn shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
347-
self.inner().shallow_size_of(ops)
348-
}
349-
}
350-
351-
impl<K, V, S> MallocSizeOf for hashglobe::protected::ProtectedHashMap<K, V, S>
352-
where K: Eq + Hash + MallocSizeOf,
353-
V: MallocSizeOf,
354-
S: BuildHasher,
355-
{
356-
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
357-
self.inner().size_of(ops)
358-
}
359-
}
360-
361342
// XXX: we don't want MallocSizeOf to be defined for Rc and Arc. If negative
362343
// trait bounds are ever allowed, this code should be uncommented.
363344
// (We do have a compile-fail test for this:

components/style/gecko/generated/bindings.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,14 +1562,6 @@ extern "C" {
15621562
extern "C" {
15631563
pub fn Gecko_GetSystemPageSize() -> usize;
15641564
}
1565-
extern "C" {
1566-
pub fn Gecko_ProtectBuffer(buffer: *mut ::std::os::raw::c_void,
1567-
size: usize);
1568-
}
1569-
extern "C" {
1570-
pub fn Gecko_UnprotectBuffer(buffer: *mut ::std::os::raw::c_void,
1571-
size: usize);
1572-
}
15731565
extern "C" {
15741566
pub fn Gecko_Construct_Default_nsStyleFont(ptr: *mut nsStyleFont,
15751567
pres_context:
@@ -2999,10 +2991,6 @@ extern "C" {
29992991
*const ServoRawOffsetArc<RustString>)
30002992
-> ServoRawOffsetArc<RustString>;
30012993
}
3002-
extern "C" {
3003-
pub fn Servo_CorruptRuleHashAndCrash(set: RawServoStyleSetBorrowed,
3004-
index: usize);
3005-
}
30062994
extern "C" {
30072995
pub fn Gecko_CreateCSSErrorReporter(sheet: *mut ServoStyleSheet,
30082996
loader: *mut Loader, uri: *mut nsIURI)

0 commit comments

Comments
 (0)