about summary refs log tree commit diff
path: root/library/std/src/sys/unix/thread.rs
diff options
context:
space:
mode:
authorYuki Okushi <huyuumi.dev@gmail.com>2021-03-17 11:33:07 +0900
committerYuki Okushi <huyuumi.dev@gmail.com>2021-03-17 12:01:55 +0900
commitf414c33e5ed47182c95d3859816424a093e0a7a9 (patch)
treef666d5abbfe59597131c17901a2c4110f33a43bf /library/std/src/sys/unix/thread.rs
parentf5d8117c338a788bd24abec733fd143dfceb25a0 (diff)
downloadrust-f414c33e5ed47182c95d3859816424a093e0a7a9.tar.gz
rust-f414c33e5ed47182c95d3859816424a093e0a7a9.zip
Display error details when a `mmap` call fails
Diffstat (limited to 'library/std/src/sys/unix/thread.rs')
-rw-r--r--library/std/src/sys/unix/thread.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/library/std/src/sys/unix/thread.rs b/library/std/src/sys/unix/thread.rs
index 40c96307514..01a12dcf5a2 100644
--- a/library/std/src/sys/unix/thread.rs
+++ b/library/std/src/sys/unix/thread.rs
@@ -231,6 +231,7 @@ pub mod guard {
     use libc::{mmap, mprotect};
     use libc::{MAP_ANON, MAP_FAILED, MAP_FIXED, MAP_PRIVATE, PROT_NONE, PROT_READ, PROT_WRITE};
 
+    use crate::io;
     use crate::ops::Range;
     use crate::sync::atomic::{AtomicUsize, Ordering};
     use crate::sys::os;
@@ -361,12 +362,12 @@ pub mod guard {
                 0,
             );
             if result != stackaddr || result == MAP_FAILED {
-                panic!("failed to allocate a guard page");
+                panic!("failed to allocate a guard page: {}", io::Error::last_os_error());
             }
 
             let result = mprotect(stackaddr, page_size, PROT_NONE);
             if result != 0 {
-                panic!("failed to protect the guard page");
+                panic!("failed to protect the guard page: {}", io::Error::last_os_error());
             }
 
             let guardaddr = stackaddr as usize;