| 84 | } |
| 85 | impl Drop for CustomStackCreator { |
| 86 | fn drop(&mut self) { |
| 87 | let page_size = rustix::param::page_size(); |
| 88 | unsafe { |
| 89 | // Unprotect the guard page as the allocator could reuse it. |
| 90 | rustix::mm::mprotect( |
| 91 | self.memory.as_ptr().cast(), |
| 92 | page_size, |
| 93 | rustix::mm::MprotectFlags::READ | rustix::mm::MprotectFlags::WRITE, |
| 94 | ) |
| 95 | .unwrap(); |
| 96 | System.dealloc(self.memory.as_ptr(), self.layout); |
| 97 | } |
| 98 | } |
| 99 | } |
| 100 | unsafe impl StackCreator for CustomStackCreator { |
| 101 | fn new_stack(&self, size: usize, zeroed: bool) -> Result<Box<dyn StackMemory>> { |