Skip to content

Commit f03493c

Browse files
committed
remove ptrace-required stuff
1 parent dfd0024 commit f03493c

File tree

3 files changed

+0
-71
lines changed

3 files changed

+0
-71
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ features = ['unprefixed_malloc_on_supported_platforms']
3939
libc = "0.2"
4040
libffi = "4.0.0"
4141
libloading = "0.8"
42-
nix = { version = "0.30.1", features = ["mman", "ptrace", "signal"] }
4342

4443
[target.'cfg(target_family = "windows")'.dependencies]
4544
windows-sys = { version = "0.59", features = [

src/discrete_alloc.rs

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
use std::alloc::{self, Layout};
22
use std::sync;
33

4-
use nix::sys::mman::ProtFlags;
5-
64
use crate::helpers::ToU64;
75

86
static ALLOCATOR: sync::Mutex<MachineAlloc> = sync::Mutex::new(MachineAlloc::empty());
@@ -219,53 +217,4 @@ impl MachineAlloc {
219217
alloc::dealloc(ptr, layout);
220218
}
221219
}
222-
223-
// Protection-related methods
224-
225-
/// Protects all owned memory, preventing accesses.
226-
///
227-
/// SAFETY: Accessing memory after this point will result in a segfault
228-
/// unless it is first unprotected.
229-
#[expect(dead_code)]
230-
pub unsafe fn prepare_ffi() -> Result<(), nix::errno::Errno> {
231-
let mut alloc = ALLOCATOR.lock().unwrap();
232-
unsafe {
233-
alloc.mprotect(ProtFlags::PROT_NONE)?;
234-
}
235-
Ok(())
236-
}
237-
238-
/// Deprotects all owned memory by setting it to RW. Erroring here is very
239-
/// likely unrecoverable, so it may panic if applying those permissions
240-
/// fails.
241-
#[expect(dead_code)]
242-
pub fn unprep_ffi() {
243-
let mut alloc = ALLOCATOR.lock().unwrap();
244-
let default_flags = ProtFlags::PROT_READ | ProtFlags::PROT_WRITE;
245-
unsafe {
246-
alloc.mprotect(default_flags).unwrap();
247-
}
248-
}
249-
250-
/// Applies `prot` to every page managed by the allocator.
251-
///
252-
/// SAFETY: Accessing memory in violation of the protection flags will
253-
/// trigger a segfault.
254-
unsafe fn mprotect(&mut self, prot: ProtFlags) -> Result<(), nix::errno::Errno> {
255-
for &pg in &self.pages {
256-
unsafe {
257-
// We already know only non-null ptrs are pushed to self.pages
258-
let addr: std::ptr::NonNull<std::ffi::c_void> =
259-
std::ptr::NonNull::new_unchecked(pg.cast());
260-
nix::sys::mman::mprotect(addr, self.page_size, prot)?;
261-
}
262-
}
263-
for &(hpg, size) in &self.huge_allocs {
264-
unsafe {
265-
let addr = std::ptr::NonNull::new_unchecked(hpg.cast());
266-
nix::sys::mman::mprotect(addr, size, prot)?;
267-
}
268-
}
269-
Ok(())
270-
}
271220
}

0 commit comments

Comments
 (0)