pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
mrust-libs: solve(?) the perpetual "guard page" problem that kept showing up when building mrust-rustc & mrust-cargo (try relying on NetBSD native guard area management instead of mprotect)
Module Name: pkgsrc-wip
Committed By: Dave Berger <pkgsrc-mrust%web5by5.com@localhost>
Pushed By: dave
Date: Sat Jan 22 16:29:10 2022 -0500
Changeset: 92fd16dbba5dd3cb6c440a4de0af9e950af20926
Modified Files:
mrust-libs/distinfo
mrust-libs/patches/patch-.._rustc-1.39.0-src_src_libstd_sys_unix_thread.rs
Log Message:
mrust-libs: solve(?) the perpetual "guard page" problem
that kept showing up when building mrust-rustc & mrust-cargo
(try relying on NetBSD native guard area management instead of mprotect)
To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=92fd16dbba5dd3cb6c440a4de0af9e950af20926
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
mrust-libs/distinfo | 2 +-
..._rustc-1.39.0-src_src_libstd_sys_unix_thread.rs | 47 ++++++++++++++--------
2 files changed, 31 insertions(+), 18 deletions(-)
diffs:
diff --git a/mrust-libs/distinfo b/mrust-libs/distinfo
index b45a5e3ede..d89e49815d 100644
--- a/mrust-libs/distinfo
+++ b/mrust-libs/distinfo
@@ -8,7 +8,7 @@ SHA1 (mrustc/rustc-1.39.0-src.tar.gz) = 82ef6f3b88b8d5e3bfa2fab67bbacf5d6f6ba6bb
RMD160 (mrustc/rustc-1.39.0-src.tar.gz) = d5b04b87fc336e3be7d592f70de0363aa66622aa
SHA512 (mrustc/rustc-1.39.0-src.tar.gz) = 77be74410b9f7a2e9f78f7a9860964e122ab9518553acc2cc80d5abeecf3302e9b3ed1fd29e022cccff1f9ff4a568b4015c0d3ac0a524f06e38e9cb360a3341e
Size (mrustc/rustc-1.39.0-src.tar.gz) = 152803201 bytes
-SHA1 (patch-.._rustc-1.39.0-src_src_libstd_sys_unix_thread.rs) = 37e12f1cc16a21d940b4cbe5ccfa0baec69d366e
+SHA1 (patch-.._rustc-1.39.0-src_src_libstd_sys_unix_thread.rs) = b787f0118df7f01a37b4f6205c4e56614ca74876
SHA1 (patch-Makefile) = 3326e1e1f9dbe83f7b3147ee073c3c821d4ce939
SHA1 (patch-minicargo.mk) = a13fa4b05e443871b8d25aa7f008069f5dd2f91d
SHA1 (patch-script-overrides_stable-1.39.0-linux_build__std.txt) = 728fce6fbbd81db342bdc1eb0f6ac57abf45f8b7
diff --git a/mrust-libs/patches/patch-.._rustc-1.39.0-src_src_libstd_sys_unix_thread.rs b/mrust-libs/patches/patch-.._rustc-1.39.0-src_src_libstd_sys_unix_thread.rs
index 0ee7061987..0177a2c313 100644
--- a/mrust-libs/patches/patch-.._rustc-1.39.0-src_src_libstd_sys_unix_thread.rs
+++ b/mrust-libs/patches/patch-.._rustc-1.39.0-src_src_libstd_sys_unix_thread.rs
@@ -2,23 +2,36 @@ $NetBSD$
--- ../rustc-1.39.0-src/src/libstd/sys/unix/thread.rs.orig 2019-11-04 15:45:21.000000000 +0000
+++ ../rustc-1.39.0-src/src/libstd/sys/unix/thread.rs
-@@ -330,14 +330,19 @@ pub mod guard {
- // than the initial mmap() used, so we mmap() here with
- // read/write permissions and only then mprotect() it to
- // no permissions at all. See issue #50313.
-- let result = mmap(stackaddr, PAGE_SIZE, PROT_READ | PROT_WRITE,
-- MAP_PRIVATE | MAP_ANON | MAP_FIXED, -1, 0);
-- if result != stackaddr || result == MAP_FAILED {
-- panic!("failed to allocate a guard page");
-- }
-+// let result = mmap(stackaddr, PAGE_SIZE, PROT_READ | PROT_WRITE,
-+// MAP_PRIVATE | MAP_ANON | MAP_FIXED, -1, 0);
-+// if result != stackaddr || result == MAP_FAILED {
-+// println!( "stackaddr = {}", stackaddr as u64 );
-+// println!( "mmap() -> result {}", result as u64 );
-+// println!( "mmap() -> ERRNO {}", os::errno() as u64 );
-+// panic!("failed to allocate a guard page");
-+// }
+@@ -321,6 +321,20 @@ pub mod guard {
+ // trust that the kernel's own stack guard will work.
+ let stackaddr = stackaddr as usize;
+ Some(stackaddr - PAGE_SIZE..stackaddr)
++ } else if cfg!(target_os = "netbsd") {
++ // [The following should be reviewed/confirmed, -DLB]:
++ // Using the default else clause below, sporadic guard page
++ // errors were occurring during builds of rustc & cargo with
++ // mrustc on NetBSD; however, NetBSD has a kernel-based
++ // guard area mechanism too. Therefore, try relying on that
++ // instead of the default mmap/mprotect solution; but note:
++ // if userland code changes the stack address, the NetBSD
++ // kernel-based guard mechanism is deactivated (see
++ // pthread_attr_getstack(3)) and the userland code must
++ // manage a guard area itself. Fortunately, the stack
++ // appears to be unchanged by this version of thread.rs
++ let stackaddr = stackaddr as usize;
++ Some(stackaddr - PAGE_SIZE..stackaddr)
+ } else {
+ // Reallocate the last page of the stack.
+ // This ensures SIGBUS will be raised on
+@@ -333,11 +347,16 @@ pub mod guard {
+ let result = mmap(stackaddr, PAGE_SIZE, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANON | MAP_FIXED, -1, 0);
+ if result != stackaddr || result == MAP_FAILED {
++ println!( "stackaddr = {}", stackaddr as u64 );
++ println!( "mmap() -> result {}", result as u64 );
++ println!( "mmap() -> ERRNO {}", os::errno() as u64 );
+ panic!("failed to allocate a guard page");
+ }
let result = mprotect(stackaddr, PAGE_SIZE, PROT_NONE);
if result != 0 {
Home |
Main Index |
Thread Index |
Old Index