Skip to content

Commit 7f85ffa

Browse files
Erk-nagisa
authored andcommitted
Merge #72
Squash commit of: commit 7762df2 Author: Valdemar Erk <valdemar@erk.dev> Date: Thu Jul 21 22:13:33 2022 +0200 panic with a specific error if allocating the stack fails. commit 818af63 Author: Valdemar Erk <valdemar@erk.io> Date: Sun Jul 10 16:17:51 2022 +0200 check errno in case of failure of either mprotect or mmap Both libc calls will set errno in case of failure so it can be used for both OpenBSD and other systems.
1 parent caabec2 commit 7f85ffa

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ psm_stack_manipulation! {
164164
0
165165
);
166166
if new_stack == libc::MAP_FAILED {
167-
panic!("unable to allocate stack")
167+
let error = std::io::Error::last_os_error();
168+
panic!("allocating stack failed with: {}", error)
168169
}
169170
let guard = StackRestoreGuard {
170171
new_stack,
@@ -191,8 +192,9 @@ psm_stack_manipulation! {
191192
-1
192193
};
193194
if result == -1 {
195+
let error = std::io::Error::last_os_error();
194196
drop(guard);
195-
panic!("unable to set stack permissions")
197+
panic!("setting stack permissions failed with: {}", error)
196198
}
197199
guard
198200
}

0 commit comments

Comments
 (0)