mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-26 23:21:35 +00:00
Unmap stack after call.
This commit is contained in:
@ -426,10 +426,10 @@ impl RunnableModule for X64ExecutionContext {
|
|||||||
callable: func,
|
callable: func,
|
||||||
};
|
};
|
||||||
use libc::{
|
use libc::{
|
||||||
mmap, mprotect, MAP_ANON, MAP_NORESERVE, MAP_PRIVATE, PROT_READ,
|
mmap, munmap, MAP_ANON, MAP_NORESERVE, MAP_PRIVATE, PROT_READ,
|
||||||
PROT_WRITE,
|
PROT_WRITE,
|
||||||
};
|
};
|
||||||
const STACK_SIZE: usize = 1048576 * 1024; // 1GB of virtual addrss space for stack.
|
const STACK_SIZE: usize = 1048576 * 1024; // 1GB of virtual address space for stack.
|
||||||
let stack_ptr = unsafe {
|
let stack_ptr = unsafe {
|
||||||
mmap(
|
mmap(
|
||||||
::std::ptr::null_mut(),
|
::std::ptr::null_mut(),
|
||||||
@ -444,11 +444,13 @@ impl RunnableModule for X64ExecutionContext {
|
|||||||
panic!("unable to allocate stack");
|
panic!("unable to allocate stack");
|
||||||
}
|
}
|
||||||
// TODO: Mark specific regions in the stack as PROT_NONE.
|
// TODO: Mark specific regions in the stack as PROT_NONE.
|
||||||
SWITCH_STACK(
|
let ret = SWITCH_STACK(
|
||||||
(stack_ptr as *mut u8).offset(STACK_SIZE as isize) as *mut u64,
|
(stack_ptr as *mut u8).offset(STACK_SIZE as isize) as *mut u64,
|
||||||
call_fn,
|
call_fn,
|
||||||
&mut cctx as *mut CallCtx as *mut u8,
|
&mut cctx as *mut CallCtx as *mut u8,
|
||||||
)
|
);
|
||||||
|
munmap(stack_ptr, STACK_SIZE);
|
||||||
|
ret
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Some(execution_context.breakpoints.clone()),
|
Some(execution_context.breakpoints.clone()),
|
||||||
|
Reference in New Issue
Block a user