🐛 Unmap only the pages the detach tests left mapped
pages_after's case 3 unmaps the second of its two pages, and every caller then unmapped both pages again. Whatever the process had mapped into that freed page in between, such as a new thread's malloc cache or the GPU driver's command buffer shared memory, was unmapped under it, and the process's next touch of it faulted. On the M3 the child of pages_without_access_on_vulkan died of SIGSEGV at exit under GPU load (merge leg 10332), the faulting write lying in the second 16 KiB page of the freed range. The tests now let go through let_go_pages_after, which unmaps only the first page after case 3. metal2vulkan's measurements of the pattern: case 3's steps beside thread starts crashed 33 of 309 children, and unmapping once, 0 of 308; a probe with case 3's cleanup, 34 of 6253, and unmapping only the first page, 0 of 5792.
This commit is contained in:
1 parent
0cce75d1e8
commit
dc013df446
1 file changed
+14
-4
@@ -1342,6 +1342,16 @@ fn pages_after(case: u8) -> HostPtr {
|
||||
at
|
||||
}
|
||||
|
||||
/// Lets go of what [`pages_after`] left mapped of its two pages at `at` for `case`: both
|
||||
/// pages, but only the first after case 3, whose second page it already unmapped. Unmapping
|
||||
/// that second page again would unmap whatever the process has mapped there since, as a new
|
||||
/// thread's malloc cache or the GPU driver's shared memory, and the process's next touch of it
|
||||
/// faults.
|
||||
fn let_go_pages_after(case: u8, at: HostPtr) {
|
||||
let length = if case == 3 { PAGE } else { 2 * PAGE };
|
||||
let _ = VulkanVm::new().deallocate(at, length);
|
||||
}
|
||||
|
||||
/// The heaps cases' options: Shared, and read-only (resource option bit 24) or not.
|
||||
fn heap_options(read_only: bool) -> Vec<OptionSet> {
|
||||
let mut options = vec![OptionSet::StorageMode(0)];
|
||||
@@ -1374,7 +1384,7 @@ fn without_access<P: Platform>(p: &P, dev: &P::Device) -> Steps {
|
||||
})
|
||||
.unwrap();
|
||||
let made = u64::from(made.heap.is_some());
|
||||
let _ = vm.deallocate(at, 2 * PAGE);
|
||||
let_go_pages_after(case, at);
|
||||
made
|
||||
});
|
||||
steps.push((
|
||||
@@ -1395,7 +1405,7 @@ fn without_access<P: Platform>(p: &P, dev: &P::Device) -> Steps {
|
||||
.unwrap();
|
||||
let replaced = u64::from(buffer.replace_backing(&array, read_only).unwrap());
|
||||
drop(buffer);
|
||||
let _ = vm.deallocate(at, 2 * PAGE);
|
||||
let_go_pages_after(case, at);
|
||||
replaced
|
||||
});
|
||||
steps.push((
|
||||
@@ -1431,7 +1441,7 @@ fn without_access<P: Platform>(p: &P, dev: &P::Device) -> Steps {
|
||||
.unwrap();
|
||||
let replaced = u64::from(heap.replace_backing(&array, read_only).unwrap());
|
||||
drop(heap);
|
||||
let _ = vm.deallocate(at, 2 * PAGE);
|
||||
let_go_pages_after(case, at);
|
||||
let _ = vm.deallocate(dummy, 2 * PAGE);
|
||||
replaced
|
||||
});
|
||||
@@ -1478,7 +1488,7 @@ fn past_the_size<P: Platform>(p: &P, dev: &P::Device) -> Steps {
|
||||
true => vec![range(at, 0, PAGE), range(at, PAGE, PAGE)],
|
||||
};
|
||||
made.push(heap_over::<P>(p, dev, &ranges, read_only));
|
||||
let _ = vm.deallocate(at, 2 * PAGE);
|
||||
let_go_pages_after(case, at);
|
||||
}
|
||||
}
|
||||
let at = pages(1, 0x5a);
|
||||
|
||||
Reference in new issue
Block a user