diff --git a/libc/integral/normalize.inc b/libc/integral/normalize.inc index a8ccdf124..30be7c9b9 100644 --- a/libc/integral/normalize.inc +++ b/libc/integral/normalize.inc @@ -68,7 +68,7 @@ /* TODO(jart): Remove this in favor of GetStackSize() */ #if defined(COSMO) && (defined(MODE_DBG) || defined(__SANITIZE_ADDRESS__)) -#define STACKSIZE 524288 /* 512kb stack */ +#define STACKSIZE 262144 /* 256kb stack */ #elif defined(COSMO) #define STACKSIZE 65536 /* 64kb stack */ #else diff --git a/libc/intrin/stracef.greg.c b/libc/intrin/stracef.greg.c index aef6fb8cc..6016ed909 100644 --- a/libc/intrin/stracef.greg.c +++ b/libc/intrin/stracef.greg.c @@ -16,8 +16,8 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/strace.internal.h" #include "libc/intrin/kprintf.h" +#include "libc/intrin/strace.internal.h" #include "libc/runtime/runtime.h" privileged void __stracef(const char *fmt, ...) { diff --git a/libc/runtime/mmap.c b/libc/runtime/mmap.c index 075606414..c4fae0c47 100644 --- a/libc/runtime/mmap.c +++ b/libc/runtime/mmap.c @@ -361,6 +361,10 @@ static noasan inline void *Mmap(void *addr, size_t size, int prot, int flags, f |= MAP_STACK_openbsd; needguard = true; } else if (IsLinux()) { + // make sure there's no existing stuff existing between our stack + // starting page and the bottom guard page, since that would stop + // our stack page from growing down. + _npassert(!sys_munmap(p, size)); // by default MAP_GROWSDOWN will auto-allocate 10mb of pages. it's // supposed to stop growing if an adjacent allocation exists, to // prevent your stacks from overlapping on each other. we're not @@ -376,8 +380,9 @@ static noasan inline void *Mmap(void *addr, size_t size, int prot, int flags, .addr == MAP_FAILED) { return MAP_FAILED; } - sys_mmap(p, PAGESIZE, PROT_NONE, MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, - -1, 0); + _npassert(sys_mmap(p, PAGESIZE, PROT_NONE, + MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0) + .addr == p); dm.addr = p; return FinishMemory(p, size, prot, flags, fd, off, f, x, n, dm); } else { diff --git a/libc/runtime/mprotect.c b/libc/runtime/mprotect.c index 3cb97a01d..09e42f5e5 100644 --- a/libc/runtime/mprotect.c +++ b/libc/runtime/mprotect.c @@ -16,12 +16,12 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/strace.internal.h" #include "libc/calls/syscall-sysv.internal.h" #include "libc/dce.h" #include "libc/errno.h" #include "libc/intrin/describeflags.internal.h" #include "libc/intrin/likely.h" +#include "libc/intrin/strace.internal.h" #include "libc/runtime/internal.h" #include "libc/sysv/consts/prot.h" diff --git a/libc/stdio/fflush.internal.h b/libc/stdio/fflush.internal.h index cc3343d3a..089d80db4 100644 --- a/libc/stdio/fflush.internal.h +++ b/libc/stdio/fflush.internal.h @@ -1,8 +1,9 @@ #ifndef COSMOPOLITAN_LIBC_STDIO_FFLUSH_H_ #define COSMOPOLITAN_LIBC_STDIO_FFLUSH_H_ #include "libc/intrin/nopl.internal.h" -#include "libc/thread/thread.h" #include "libc/stdio/stdio.h" +#include "libc/thread/thread.h" +#include "libc/thread/tls.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ diff --git a/libc/sysv/consts.sh b/libc/sysv/consts.sh index 3351a3062..bd31fa9bd 100755 --- a/libc/sysv/consts.sh +++ b/libc/sysv/consts.sh @@ -579,8 +579,6 @@ syscon sicode SYS_USER_DISPATCH 2 -1 -1 -1 -1 -1 # SIGSYS; syscall # sigaltstack() values # # group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary -syscon ss SIGSTKSZ 8192 131072 34816 28672 28672 8192 # overlaid with FRAMESIZE; you need to #undef SIGSTKSZ to access this symbol -syscon ss MINSIGSTKSZ 2048 32768 2048 12288 8192 2048 # overlaid with 32768; you need to #undef MINSIGSTKSZ to access this symbol syscon ss SS_ONSTACK 1 1 1 1 1 1 # unix consensus syscon ss SS_DISABLE 2 4 4 4 4 2 # bsd consensus diff --git a/libc/sysv/consts/MINSIGSTKSZ.s b/libc/sysv/consts/MINSIGSTKSZ.s deleted file mode 100644 index 3100db969..000000000 --- a/libc/sysv/consts/MINSIGSTKSZ.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/consts/syscon.internal.inc" -.syscon ss,MINSIGSTKSZ,2048,32768,2048,12288,8192,2048 diff --git a/libc/sysv/consts/SIGSTKSZ.s b/libc/sysv/consts/SIGSTKSZ.s deleted file mode 100644 index b41bb53bc..000000000 --- a/libc/sysv/consts/SIGSTKSZ.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/consts/syscon.internal.inc" -.syscon ss,SIGSTKSZ,8192,131072,34816,28672,28672,8192 diff --git a/libc/sysv/consts/ss.h b/libc/sysv/consts/ss.h index 9f05e231c..64a8149f8 100644 --- a/libc/sysv/consts/ss.h +++ b/libc/sysv/consts/ss.h @@ -3,15 +3,13 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -extern const size_t SIGSTKSZ; -extern const size_t MINSIGSTKSZ; extern const int SS_DISABLE; COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ -#define SIGSTKSZ FRAMESIZE -#define MINSIGSTKSZ 32768 +#define SIGSTKSZ 32768 +#define MINSIGSTKSZ 32768 /* xnu defines the highest minimum */ #define SS_ONSTACK 1 #define SS_DISABLE SS_DISABLE