cosmopolitan/libc/log
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
..
thunks Remove more nonstandard stuff from cosmopolitan.h 2021-03-01 00:18:23 -08:00
addr2linepath.c Make numerous improvements 2021-09-28 01:52:34 -07:00
appendresourcereport.c Make numerous improvements 2021-09-28 01:52:34 -07:00
attachdebugger.c Improve system call support 2021-08-25 21:36:17 -07:00
backtrace.internal.h Get Cosmopolitan into releasable state 2020-11-25 08:19:00 -08:00
backtrace2.c Improve memory safety 2021-10-13 17:27:13 -07:00
backtrace3.c Improve memory safety 2021-10-13 17:27:13 -07:00
bsd.h Add chibicc 2020-12-06 16:20:21 -08:00
cancolor.c Make numerous improvements 2021-09-28 01:52:34 -07:00
check.h Undiamond Python headers 2021-08-12 14:07:40 -07:00
checkaligned.c Add cpu / mem / fsz limits to build system 2021-08-13 23:40:53 -07:00
checkfail.c Make numerous improvements 2021-09-28 01:52:34 -07:00
checkfail_ndebug.c Add cpu / mem / fsz limits to build system 2021-08-13 23:40:53 -07:00
color.internal.h Get Cosmopolitan into releasable state 2020-11-25 08:19:00 -08:00
commandvenv.c Make numerous improvements 2021-09-28 01:52:34 -07:00
countbranch.h Make numerous improvements 2021-09-28 01:52:34 -07:00
countbranch_data.S Make numerous improvements 2021-09-28 01:52:34 -07:00
countbranch_report.c Make numerous improvements 2021-09-28 01:52:34 -07:00
cxaprintexits.c Improve memory safety 2021-10-13 17:27:13 -07:00
die.c Improve memory safety 2021-10-13 17:27:13 -07:00
err.c Change license 2020-12-27 17:18:44 -08:00
errx.c Change license 2020-12-27 17:18:44 -08:00
flogf.c Change license 2020-12-27 17:18:44 -08:00
gdb.h Remove dollars from system call support symbols 2021-02-03 19:35:29 -08:00
gdbexec.c Make major improvements to redbean and libraries 2021-04-18 12:34:15 -07:00
gdbpath.c Change license 2020-12-27 17:18:44 -08:00
gdbsync.c Change license 2020-12-27 17:18:44 -08:00
getcallername.c Improve memory safety 2021-10-13 17:27:13 -07:00
getsicodename.c Make numerous improvements 2021-09-28 01:52:34 -07:00
getsymbolbyaddr.c Improve memory safety 2021-10-13 17:27:13 -07:00
getsymboltable.c Improve memory safety 2021-10-13 17:27:13 -07:00
getttycols.c Change license 2020-12-27 17:18:44 -08:00
getttysize.c Remove more nonstandard stuff from cosmopolitan.h 2021-03-01 00:18:23 -08:00
internal.h Improve memory safety 2021-10-13 17:27:13 -07:00
libfatal.internal.h Improve memory safety 2021-10-13 17:27:13 -07:00
log.h Improve memory safety 2021-10-13 17:27:13 -07:00
log.mk Make numerous improvements 2021-09-28 01:52:34 -07:00
logerrno.c Make Cosmopolitan ANSI C89 compatible 2021-02-03 17:48:59 -08:00
logfile.initabi.c Remove more nonstandard stuff from cosmopolitan.h 2021-03-01 00:18:23 -08:00
loglevel.S Remove more nonstandard stuff from cosmopolitan.h 2021-03-01 00:18:23 -08:00
malloc_stats.c Add cpu / mem / fsz limits to build system 2021-08-13 23:40:53 -07:00
meminfo.c Add cpu / mem / fsz limits to build system 2021-08-13 23:40:53 -07:00
memsummary.c Support proper %g, %f, and %a float formatting 2021-03-05 10:31:16 -08:00
oncrash.c Improve memory safety 2021-10-13 17:27:13 -07:00
oncrashthunks.S Add cpu / mem / fsz limits to build system 2021-08-13 23:40:53 -07:00
onkill.c Make numerous improvements 2021-09-28 01:52:34 -07:00
perror.c Make minor improvements 2021-05-15 21:53:26 -07:00
printgarbage.c Improve memory safety 2021-10-13 17:27:13 -07:00
printgarbagenumeric.c Fix regression in _gclongjmp() 2021-08-19 09:34:24 -07:00
restoretty.c Make numerous improvements 2021-09-28 01:52:34 -07:00
showcrashreports.c Improve memory safety 2021-10-13 17:27:13 -07:00
startfatal.c Make numerous improvements 2021-09-28 01:52:34 -07:00
startfatal_ndebug.c Make numerous improvements 2021-09-28 01:52:34 -07:00
traceme.c Undiamond Python headers 2021-08-12 14:07:40 -07:00
traceme.h Undiamond Python headers 2021-08-12 14:07:40 -07:00
verr.c Change license 2020-12-27 17:18:44 -08:00
verrx.c Change license 2020-12-27 17:18:44 -08:00
vflogf.c Improve logger API (#262) 2021-09-03 21:14:26 -07:00
vwarn.c Change license 2020-12-27 17:18:44 -08:00
vwarnx.c Change license 2020-12-27 17:18:44 -08:00
warn.c Change license 2020-12-27 17:18:44 -08:00
warnx.c Change license 2020-12-27 17:18:44 -08:00