mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-03 08:20:28 +00:00
Improve memory safety
This commit makes numerous refinements to cosmopolitan memory handling. The default stack size has been reduced from 2mb to 128kb. A new macro is now provided so you can easily reconfigure the stack size to be any value you want. Work around the breaking change by adding to your main: STATIC_STACK_SIZE(0x00200000); // 2mb stack If you're not sure how much stack you need, then you can use: STATIC_YOINK("stack_usage_logging"); After which you can `sort -nr o/$MODE/stack.log`. Based on the unit test suite, nothing in the Cosmopolitan repository (except for Python) needs a stack size greater than 30kb. There are also new macros for detecting the size and address of the stack at runtime, e.g. GetStackAddr(). We also now support sigaltstack() so if you want to see nice looking crash reports whenever a stack overflow happens, you can put this in main(): ShowCrashReports(); Under `make MODE=dbg` and `make MODE=asan` the unit testing framework will now automatically print backtraces of memory allocations when things like memory leaks happen. Bugs are now fixed in ASAN global variable overrun detection. The memtrack and asan runtimes also handle edge cases now. The new tools helped to identify a few memory leaks, which are fixed by this change. This change should fix an issue reported in #288 with ARG_MAX limits. Fixing this doubled the performance of MKDEPS.COM and AR.COM yet again.
This commit is contained in:
parent
a0b39f886c
commit
226aaf3547
317 changed files with 6474 additions and 3993 deletions
|
@ -47,7 +47,7 @@ scall sys_lseek 0x0c70c71de20c7008 globl hidden # netbsd+openbsd:evilpad
|
|||
scall __sys_mmap 0x0c50c51dd20c5009 globl hidden # netbsd+openbsd:pad
|
||||
scall sys_msync 0x115100041204101a globl hidden
|
||||
scall sys_mprotect 0x04a04a04a204a00a globl hidden
|
||||
scall sys_munmap 0x049049049204900b globl hidden
|
||||
scall __sys_munmap 0x049049049204900b globl hidden
|
||||
scall sys_sigaction 0x15402e1a0202e00d globl hidden # rt_sigaction on Lunix; it's complicated on NetBSD
|
||||
scall sys_sigprocmask 0x125030154203000e globl hidden # a.k.a. rt_sigprocmask, openbsd:byvalue
|
||||
scall sys_ioctl 0x0360360362036010 globl hidden
|
||||
|
@ -164,7 +164,7 @@ scall getresuid 0xfff119168ffff076 globl # semantics aren't well-defined
|
|||
scall getresgid 0xfff11b169ffff078 globl # semantics aren't well-defined
|
||||
scall sigpending 0x124034034203407f globl # rt_sigpending on linux
|
||||
scall sys_sigsuspend 0x12606f155206f082 globl hidden # openbsd:byvalue
|
||||
scall sigaltstack 0x1191200352035083 globl
|
||||
scall sys_sigaltstack 0x1191200352035083 globl hidden
|
||||
scall sys_mknod 0x1c200e00e200e085 globl hidden
|
||||
scall mknodat 0x1cc14022fffff103 globl # FreeBSD 12+
|
||||
scall sys_mkfifo 0x0840840842084fff globl hidden
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue