-
Notifications
You must be signed in to change notification settings - Fork 66
Open
Description
Hey, I was experimenting with your code when I found that the stack_area() function includes an extra guard page in the usable size... unless I'm using it wrong? I believe that the stack area includes 2 guard pages and only 1 of them is subtracted. I have a test that fails, and switching it to subtract 2 guard pages fixes my test.
Test (in mmap stack restore guard file):
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_stack_area() {
for stack_size_kb in 1..64 {
let size = stack_size_kb * 1024;
let stack = StackRestoreGuard::new(size);
assert_eq!(
stack.stack_area().1,
((size + page_size() - 1) / page_size()) * page_size()
)
}
}
}Fix:
pub fn stack_area(&self) -> (*mut u8, usize) {
unsafe {
(
self.mapping.add(self.page_size),
self.size_with_guard - 2 * self.page_size,
)
}
}Fixing this could allow you to pass in the allocated_stack_size instead of requested_stack_size in lib.rs:161
Metadata
Metadata
Assignees
Labels
No labels