cosmopolitan/examples
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
..
package Remove more nonstandard stuff from cosmopolitan.h 2021-03-01 00:18:23 -08:00
pyapp Improve Python and Linenoise 2021-09-11 22:30:37 -07:00
auto-launch-gdb-on-crash.c Make improvements 2020-12-01 03:43:40 -08:00
breakpoint.c Make numerous improvements 2021-09-28 01:52:34 -07:00
certapp.c Improve ZIP filesystem and change its prefix 2021-08-22 01:11:53 -07:00
cp.c Add smoke test for timezone loading (#114) 2021-03-08 11:46:04 -08:00
cplusplus.cc Remove more nonstandard stuff from cosmopolitan.h 2021-03-01 00:18:23 -08:00
crashreport.c Make examples folder somewhat more focused 2021-03-05 06:09:12 -08:00
ctrlc.c Improve memory safety 2021-10-13 17:27:13 -07:00
curl.c Refactor out some duplicated code 2021-08-14 06:17:56 -07:00
date.c Add smoke test for timezone loading (#114) 2021-03-08 11:46:04 -08:00
defer-statements.c Make mappings unlimited on NT 2021-09-04 13:20:47 -07:00
echo.c Fix XNU / FreeBSD / OpenBSD / RHEL5 / NT bugs 2021-01-25 18:31:17 -08:00
examples.mk [WIP] Threading (#282) 2021-10-13 11:26:05 -07:00
exec.c Productionize new APE loader and more 2021-10-02 08:27:03 -07:00
fastdiv.c Add SNI support to redbean and improve SSL perf 2021-07-23 13:56:13 -07:00
fastmod.c Fix some example code 2021-08-10 13:38:27 -07:00
forkrand.c Make improvements 2020-12-01 03:43:40 -08:00
generalized-automatic-datastructure-printing.c Initial import 2020-06-15 07:18:57 -07:00
getcpucount.c Undiamond Python headers 2021-08-12 14:07:40 -07:00
getrandom.c Improve memory safety 2021-10-13 17:27:13 -07:00
gui.c Make examples folder somewhat more focused 2021-03-05 06:09:12 -08:00
hangman.c Add epoll and do more release readiness changes 2020-11-28 12:01:51 -08:00
hello.c Make examples folder somewhat more focused 2021-03-05 06:09:12 -08:00
hello2.c Trim down executable sizes 2021-02-11 08:37:18 -08:00
hello3.c Improve performance of printf functions 2021-04-24 13:58:50 -07:00
hellolua.c Improve ZIP filesystem and change its prefix 2021-08-22 01:11:53 -07:00
hellolua.lua Add Hello World example for LUA C API (#97) 2021-03-08 14:15:59 -08:00
hertz.c Fix bugs and make improvements 2021-05-01 05:11:35 -07:00
hostname.c Fix XNU / FreeBSD / OpenBSD / RHEL5 / NT bugs 2021-01-25 18:31:17 -08:00
img.c Add example for printing <img> tag 2021-07-04 15:41:43 -07:00
ispell.c Improve ZIP filesystem and change its prefix 2021-08-22 01:11:53 -07:00
kilo.c Improve linenoise and get it working on Windows 2021-08-15 14:34:05 -07:00
life.c Initial import 2020-06-15 07:18:57 -07:00
ls.c Add smoke test for timezone loading (#114) 2021-03-08 11:46:04 -08:00
lstime.c Add smoke test for timezone loading (#114) 2021-03-08 11:46:04 -08:00
nc.c Add half close flag to netcat example 2021-06-15 11:24:24 -07:00
nesemu1.cc Improve ZIP filesystem and change its prefix 2021-08-22 01:11:53 -07:00
panels.c Make more major improvements to redbean 2021-04-20 19:14:21 -07:00
printargs.c Productionize new APE loader and more 2021-10-02 08:27:03 -07:00
printprimes.c Fold conv package into fmt 2020-12-09 16:52:00 -08:00
rusage.c Improve memory safety 2021-10-13 17:27:13 -07:00
seq.c Fix sigsuspend() and sigprocmask() on OpenBSD 2021-02-05 12:19:43 -08:00
sleep.c Work towards improving signals and processes 2021-01-27 19:34:02 -08:00
stackoverflow.c Improve memory safety 2021-10-13 17:27:13 -07:00
stat.c Make numerous improvements 2021-09-28 01:52:34 -07:00
stringbuffer.c Add SNI support to redbean and improve SSL perf 2021-07-23 13:56:13 -07:00
system.c Fix XNU / FreeBSD / OpenBSD / RHEL5 / NT bugs 2021-01-25 18:31:17 -08:00
thread.c [WIP] Threading (#282) 2021-10-13 11:26:05 -07:00
time.c Improve ZIP filesystem and change its prefix 2021-08-22 01:11:53 -07:00
touch.c Improve build system 2021-02-19 23:03:34 -08:00
ttyinfo.c Make fixes, improvements, and chibicc python bindings 2021-10-08 08:41:57 -07:00
ucontext-sigfpe-recovery.c Improve signal handling and math 2021-02-25 18:33:33 -08:00
unbourne.c Improve memory safety 2021-10-13 17:27:13 -07:00
walk.c Add SSL to redbean 2021-06-24 13:20:50 -07:00
x86split.c Make examples folder somewhat more focused 2021-03-05 06:09:12 -08:00