cosmopolitan/libc/runtime
Justine Tunney 226aaf3547 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.
2021-10-13 17:27:13 -07:00
..
abort-nt.c Improve memory safety 2021-10-13 17:27:13 -07:00
abort.S Remove more nonstandard stuff from cosmopolitan.h 2021-03-01 00:18:23 -08:00
arch_prctl.c Support malloc() on bare metal 2021-02-24 00:53:24 -08:00
arememoryintervalsok.c Improve memory safety 2021-10-13 17:27:13 -07:00
assertfail.c Apply fixes and speedups 2021-10-04 03:23:31 -07:00
brk.c Remove more nonstandard stuff from cosmopolitan.h 2021-03-01 00:18:23 -08:00
buffer.h Initial import 2020-06-15 07:18:57 -07:00
clearenv.c Change license 2020-12-27 17:18:44 -08:00
clktck.c Get more Python tests passing (#141) 2021-08-16 15:26:31 -07:00
clktck.h Make major improvements to redbean and libraries 2021-04-18 12:34:15 -07:00
clone.c Improve system call support 2021-08-25 21:36:17 -07:00
close_s.c Change license 2020-12-27 17:18:44 -08:00
closesymboltable.c Make numerous improvements 2021-09-28 01:52:34 -07:00
construct.S Remove more nonstandard stuff from cosmopolitan.h 2021-03-01 00:18:23 -08:00
cosmo.S Make numerous improvements 2021-09-28 01:52:34 -07:00
cxaatexit.internal.h Improve memory safety 2021-10-13 17:27:13 -07:00
describeframe.c Improve memory safety 2021-10-13 17:27:13 -07:00
describemapping.c Improve memory safety 2021-10-13 17:27:13 -07:00
describeos.c Change license 2020-12-27 17:18:44 -08:00
directmap-metal.c Improve memory safety 2021-10-13 17:27:13 -07:00
directmap-nt.c Improve memory safety 2021-10-13 17:27:13 -07:00
directmap.c Improve memory safety 2021-10-13 17:27:13 -07:00
directmap.internal.h Support malloc() on bare metal 2021-02-24 00:53:24 -08:00
dlfcn.h Get Fabrice Bellard's JavaScript engine to build 2021-04-09 01:06:57 -07:00
dsohandle.S Remove more nonstandard stuff from cosmopolitan.h 2021-03-01 00:18:23 -08:00
e820.internal.h Support malloc() on bare metal 2021-02-24 00:53:24 -08:00
efimain.greg.c Remove more nonstandard stuff from cosmopolitan.h 2021-03-01 00:18:23 -08:00
exit.c Restore Windows command prompt mode on exit 2021-02-27 12:53:51 -08:00
exit2.c Support malloc() on bare metal 2021-02-24 00:53:24 -08:00
ezmap.c Make numerous improvements 2021-09-28 01:52:34 -07:00
ezmap.internal.h Improve documentation 2020-12-27 07:02:35 -08:00
fegetround.c Get Fabrice Bellard's JavaScript engine to build 2021-04-09 01:06:57 -07:00
fenv.c Get Fabrice Bellard's JavaScript engine to build 2021-04-09 01:06:57 -07:00
fenv.h Get Fabrice Bellard's JavaScript engine to build 2021-04-09 01:06:57 -07:00
fesetround.c Fix issues revealed by ECMAScript test262 2021-04-10 17:15:35 -07:00
findcombinary.c Improve ZIP filesystem and change its prefix 2021-08-22 01:11:53 -07:00
finddebugbinary.c Improve ZIP filesystem and change its prefix 2021-08-22 01:11:53 -07:00
fltrounds.c Fix issues revealed by ECMAScript test262 2021-04-10 17:15:35 -07:00
fork-nt.c Productionize new APE loader and more 2021-10-02 08:27:03 -07:00
fork.c Make redbean tinier 2021-07-04 12:26:54 -07:00
fpreset.S Remove more nonstandard stuff from cosmopolitan.h 2021-03-01 00:18:23 -08:00
free_s.c Expose public garbage collector API for C language 2021-03-08 10:59:34 -08:00
ftrace-hook.S Improve memory safety 2021-10-13 17:27:13 -07:00
ftrace.c Improve memory safety 2021-10-13 17:27:13 -07:00
ftraceinit.c Improve performance of printf functions 2021-04-24 13:58:50 -07:00
ftracer.c Improve memory safety 2021-10-13 17:27:13 -07:00
gc.h Expose public garbage collector API for C language 2021-03-08 10:59:34 -08:00
gc.internal.h Fix regression in _gclongjmp() 2021-08-19 09:34:24 -07:00
getcpucount.c Get more Python tests passing (#141) 2021-08-16 15:26:31 -07:00
getdosargv.c Improve some unicode functions 2021-05-05 07:25:39 -07:00
getdosenviron.c Make numerous improvements 2021-09-28 01:52:34 -07:00
getmaxfd.c Improve Libc by making Python work even better 2021-08-18 22:16:23 -07:00
getpagesize.S Remove more nonstandard stuff from cosmopolitan.h 2021-03-01 00:18:23 -08:00
getresourcelimit.c Improve Libc by making Python work even better 2021-08-18 22:16:23 -07:00
getsymbol.c Improve memory safety 2021-10-13 17:27:13 -07:00
getsymbolname.c Improve memory safety 2021-10-13 17:27:13 -07:00
grow.c Make numerous improvements 2021-09-28 01:52:34 -07:00
hook.greg.c Make fixes, improvements, and chibicc python bindings 2021-10-08 08:41:57 -07:00
init.S Remove more nonstandard stuff from cosmopolitan.h 2021-03-01 00:18:23 -08:00
internal.h Restore Windows command prompt mode on exit 2021-02-27 12:53:51 -08:00
interruptiblecall.c Remove more nonstandard stuff from cosmopolitan.h 2021-03-01 00:18:23 -08:00
interruptiblecall.h Initial import 2020-06-15 07:18:57 -07:00
isheap.c Improve memory safety 2021-10-13 17:27:13 -07:00
issetugid.c Change license 2020-12-27 17:18:44 -08:00
jmpstack.S Remove more nonstandard stuff from cosmopolitan.h 2021-03-01 00:18:23 -08:00
ldso.c Get Fabrice Bellard's JavaScript engine to build 2021-04-09 01:06:57 -07:00
mapanon.c Improve memory safety 2021-10-13 17:27:13 -07:00
mapelfread.c Change license 2020-12-27 17:18:44 -08:00
memtrack.c Improve memory safety 2021-10-13 17:27:13 -07:00
memtrack.internal.h Improve memory safety 2021-10-13 17:27:13 -07:00
memtracknt.c Make numerous improvements 2021-09-28 01:52:34 -07:00
metalprintf.greg.c Support malloc() on bare metal 2021-02-24 00:53:24 -08:00
metalprintf.internal.h Support malloc() on bare metal 2021-02-24 00:53:24 -08:00
mman.greg.c Bring life.com executable size back down to 12kb 2021-03-02 01:13:32 -08:00
mman.internal.h Support malloc() on bare metal 2021-02-24 00:53:24 -08:00
mmap.c Improve memory safety 2021-10-13 17:27:13 -07:00
mmi.c Make mappings unlimited on NT 2021-09-04 13:20:47 -07:00
mmi.init.S Make mappings unlimited on NT 2021-09-04 13:20:47 -07:00
mremap-sysv.c Make major improvements to redbean and libraries 2021-04-18 12:34:15 -07:00
mremap.c Improve memory safety 2021-10-13 17:27:13 -07:00
msync-nt.c Make numerous improvements 2021-09-28 01:52:34 -07:00
msync.c Make redbean StoreAsset() work better 2021-05-14 05:44:37 -07:00
munmap-metal.c Improve memory safety 2021-10-13 17:27:13 -07:00
munmap-sysv.c Improve memory safety 2021-10-13 17:27:13 -07:00
munmap.c Improve memory safety 2021-10-13 17:27:13 -07:00
openexecutable.S Improve ZIP filesystem and change its prefix 2021-08-22 01:11:53 -07:00
opensymboltable.c Improve memory safety 2021-10-13 17:27:13 -07:00
pc.internal.h Improve signal handling and math 2021-02-25 18:33:33 -08:00
peekall.S Reduce number of disk seeks in redbean 2021-05-03 01:21:50 -07:00
print.greg.c Expose public garbage collector API for C language 2021-03-08 10:59:34 -08:00
printmemoryintervals.c Improve memory safety 2021-10-13 17:27:13 -07:00
progname.S Remove more nonstandard stuff from cosmopolitan.h 2021-03-01 00:18:23 -08:00
program_executable_name.c Improve memory safety 2021-10-13 17:27:13 -07:00
program_invocation_short_name.S Remove more nonstandard stuff from cosmopolitan.h 2021-03-01 00:18:23 -08:00
pthread.c Work towards improving signals and processes 2021-01-27 19:34:02 -08:00
quick_exit.c Improve memory safety 2021-10-13 17:27:13 -07:00
runtime.h Improve memory safety 2021-10-13 17:27:13 -07:00
runtime.mk Apply fixes and speedups 2021-10-04 03:23:31 -07:00
setstack.S Remove more nonstandard stuff from cosmopolitan.h 2021-03-01 00:18:23 -08:00
stack.h Improve memory safety 2021-10-13 17:27:13 -07:00
stackchkfail.c Expose public garbage collector API for C language 2021-03-08 10:59:34 -08:00
stackchkfaillocal.c Change license 2020-12-27 17:18:44 -08:00
stackuse.c Improve memory safety 2021-10-13 17:27:13 -07:00
symbolic.h wip on intellisense (again) 2021-02-02 11:14:45 -05:00
symbols.internal.h Improve memory safety 2021-10-13 17:27:13 -07:00
sysconf.c Improve Libc by making Python work even better 2021-08-18 22:16:23 -07:00
sysconf.h Fix a few more Python tests 2021-08-16 23:47:47 -07:00
untrackmemoryintervals.c Make mappings unlimited on NT 2021-09-04 13:20:47 -07:00
valist.c Remove more nonstandard stuff from cosmopolitan.h 2021-03-01 00:18:23 -08:00
valist.h Further refine documentation 2020-12-27 17:05:03 -08:00
vfork.S Fix popen_test in MODE=dbg 2021-05-01 17:13:48 -07:00
weakfree.c Expose public garbage collector API for C language 2021-03-08 10:59:34 -08:00
winmain.greg.c Improve memory safety 2021-10-13 17:27:13 -07:00