Skip to content

Commit 8ecbec1

Browse files
committed
Use mprotect instead of mmap
1 parent d39b02c commit 8ecbec1

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/libstd/sys/unix/thread.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -355,10 +355,9 @@ pub mod guard {
355355
// macOS. Instead, just restore the page to a writable state.
356356
// This ain't Linux, so we probably don't need to care about
357357
// execstack.
358-
let result = mmap(stackaddr, PAGE_SIZE, PROT_READ | PROT_WRITE,
359-
MAP_PRIVATE | MAP_ANON | MAP_FIXED, -1, 0);
358+
let result = mprotect(stackaddr, PAGE_SIZE, PROT_READ | PROT_WRITE);
360359

361-
if result != stackaddr || result == MAP_FAILED {
360+
if result != 0 {
362361
panic!("unable to reset the guard page");
363362
}
364363
}

0 commit comments

Comments
 (0)