File tree 1 file changed +12
-9
lines changed
library/std/src/sys/pal/unix
1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -419,6 +419,7 @@ mod imp {
419
419
Some ( stackaddr - page_size..stackaddr)
420
420
}
421
421
422
+ #[ forbid( unsafe_op_in_unsafe_fn) ]
422
423
unsafe fn install_main_guard_default ( page_size : usize ) -> Option < Range < usize > > {
423
424
// Reallocate the last page of the stack.
424
425
// This ensures SIGBUS will be raised on
@@ -429,19 +430,21 @@ mod imp {
429
430
// read/write permissions and only then mprotect() it to
430
431
// no permissions at all. See issue #50313.
431
432
let stackptr = stack_start_aligned ( page_size) ?;
432
- let result = mmap64 (
433
- stackptr,
434
- page_size,
435
- PROT_READ | PROT_WRITE ,
436
- MAP_PRIVATE | MAP_ANON | MAP_FIXED ,
437
- -1 ,
438
- 0 ,
439
- ) ;
433
+ let result = unsafe {
434
+ mmap64 (
435
+ stackptr,
436
+ page_size,
437
+ PROT_READ | PROT_WRITE ,
438
+ MAP_PRIVATE | MAP_ANON | MAP_FIXED ,
439
+ -1 ,
440
+ 0 ,
441
+ )
442
+ } ;
440
443
if result != stackptr || result == MAP_FAILED {
441
444
panic ! ( "failed to allocate a guard page: {}" , io:: Error :: last_os_error( ) ) ;
442
445
}
443
446
444
- let result = mprotect ( stackptr, page_size, PROT_NONE ) ;
447
+ let result = unsafe { mprotect ( stackptr, page_size, PROT_NONE ) } ;
445
448
if result != 0 {
446
449
panic ! ( "failed to protect the guard page: {}" , io:: Error :: last_os_error( ) ) ;
447
450
}
You can’t perform that action at this time.
0 commit comments