-
Notifications
You must be signed in to change notification settings - Fork 13.3k
stack overflow handler specific openbsd change. #87528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,14 +143,15 @@ mod imp { | |
} | ||
|
||
unsafe fn get_stackp() -> *mut libc::c_void { | ||
let stackp = mmap( | ||
ptr::null_mut(), | ||
SIGSTKSZ + page_size(), | ||
PROT_READ | PROT_WRITE, | ||
MAP_PRIVATE | MAP_ANON, | ||
-1, | ||
0, | ||
); | ||
// OpenBSD requires this flag for stack mapping | ||
// otherwise the said mapping will fail as a no-op on most systems | ||
// and has a different meaning on FreeBSD | ||
#[cfg(any(target_os = "openbsd", target_os = "netbsd", target_os = "linux",))] | ||
let flags = MAP_PRIVATE | MAP_ANON | libc::MAP_STACK; | ||
#[cfg(not(any(target_os = "openbsd", target_os = "netbsd", target_os = "linux",)))] | ||
let flags = MAP_PRIVATE | MAP_ANON; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Linux supports There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes but not necessary on these oses plus solaris/illumos does not have it and I believe haiku neither. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Not currently necessary. A future architecture may need it. That is why it exists as no-op at all. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok can add for linux, netbsd but I m less sure about FreeBSD the flag is working but does not seem to work well with null start addresses, seems little usage difference. |
||
let stackp = | ||
mmap(ptr::null_mut(), SIGSTKSZ + page_size(), PROT_READ | PROT_WRITE, flags, -1, 0); | ||
if stackp == MAP_FAILED { | ||
panic!("failed to allocate an alternative stack: {}", io::Error::last_os_error()); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"this flag" is referring to
MAP_STACK
? If so the comment is on the wrong line.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed :)