File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -93,7 +93,19 @@ pub mod guard {
9393
9494 PAGE_SIZE = psize as uint ;
9595
96- let stackaddr = get_stack_start ( ) ;
96+ let mut stackaddr = get_stack_start ( ) ;
97+
98+ // Ensure stackaddr is page aligned! A parent process might
99+ // have reset RLIMIT_STACK to be non-page aligned. The
100+ // pthread_attr_getstack() reports the usable stack area
101+ // stackaddr < stackaddr + stacksize, so if stackaddr is not
102+ // page-aligned, calculate the fix such that stackaddr <
103+ // new_page_aligned_stackaddr < stackaddr + stacksize
104+ let remainder = ( stackaddr as usize ) % ( PAGE_SIZE as usize ) ;
105+ if remainder != 0 {
106+ stackaddr = ( ( stackaddr as usize ) + ( PAGE_SIZE as usize ) - remainder)
107+ as * mut libc:: c_void ;
108+ }
97109
98110 // Rellocate the last page of the stack.
99111 // This ensures SIGBUS will be raised on
You can’t perform that action at this time.
0 commit comments