cosmopolitan/libc/runtime
Justine Tunney dc1afc968b
Fix fork() crash on Windows
On Windows, sometimes fork() could crash with message likes:

    fork() ViewOrDie(170000) failed with win32 error 487

This is due to a bug in our file descriptor inheritance. We have cursors
which are shared between processes. They let us track the file positions
of read() and write() operations. At startup they were being mmap()ed to
memory addresses that were assigned by WIN32. That's bad because Windows
likes to give us memory addresses beneath the program image in the first
4mb range that are likely to conflict with other assignments. That ended
up causing problems because fork() needs to be able to assume that a map
will be possible to resurrect at the same address. But for one reason or
another, Windows libraries we don't control could sneak allocations into
the memory space that overlap with these mappings. This change solves it
by choosing a random memory address instead when mapping cursor objects.
2024-10-12 15:38:58 -07:00
..
.cosmo Move zipos into runtime package 2023-08-11 23:14:02 -07:00
__sigsetjmp_tail.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
at_quick_exit.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
BUILD.mk Fix build break 2024-06-29 04:34:27 -07:00
clktck.h Reduce header complexity 2023-11-28 14:39:42 -08:00
clone-linux.S Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
clone-openbsd.S Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
clone-xnu.S Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
clone.c Avoid an --ftrace crash on Windows 2024-10-07 18:39:25 -07:00
closesymboltable.c Apply clang-format update to repo (#1154) 2024-04-25 10:38:00 -07:00
cosmo.S Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
cosmo2.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
cxa_thread_atexit.c Improve multithreading 2024-07-21 14:40:45 -07:00
e820.internal.h Support malloc() on bare metal 2021-02-24 00:53:24 -08:00
efimain.greg.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
efipostboot.S Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
enable_tls.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
exit.c Get rid of .internal.h convention in LIBC_INTRIN 2024-07-19 19:38:00 -07:00
fenv.h Introduce support for trapping math 2024-04-30 13:38:43 -07:00
findcombinary.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
fltrounds.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
fpathconf.c Apply clang-format update to repo (#1154) 2024-04-25 10:38:00 -07:00
fpreset.S Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
ftrace-hook.S Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
ftrace_install.c Rewrite memory manager 2024-06-22 05:45:11 -07:00
ftrace_stackdigs.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
ftraceinit.greg.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
ftracer.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
getargmax.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
getavphyspages.c Create variables for page size 2024-07-18 21:16:53 -07:00
getdosargv.c Apply clang-format update to repo (#1154) 2024-04-25 10:38:00 -07:00
getdosenviron.c Apply clang-format update to repo (#1154) 2024-04-25 10:38:00 -07:00
getinterpreterexecutablename.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
getlogin.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
getlogin_r.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
getphyspages.c Create variables for page size 2024-07-18 21:16:53 -07:00
getresourcelimit.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
getsymbol.c Make improvements 2024-09-01 01:27:47 -07:00
getsymbolbyaddr.c Apply clang-format update to repo (#1154) 2024-04-25 10:38:00 -07:00
getsymbolname.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
getsymboltable.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
getsysctl.c Add sysctlbyname() for MacOS 2024-05-02 23:21:43 -07:00
hook.greg.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
inflate.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
init.S Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
interceptflag.greg.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
internal.h Rewrite memory manager 2024-06-22 05:45:11 -07:00
isstackoverflow.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
jit.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
login_tty.c Get rid of .internal.h convention in LIBC_INTRIN 2024-07-19 19:38:00 -07:00
mapstack.c Make mmap() scalable 2024-07-05 23:26:00 -07:00
memtrack.internal.h Fix bugs with new memory manager 2024-06-29 10:53:57 -07:00
metalprintf.greg.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
metalprintf.internal.h Reduce header complexity 2023-11-28 14:39:42 -08:00
mman.internal.h Reduce header complexity 2023-11-28 14:39:42 -08:00
morph.c Apply clang-format update to repo (#1154) 2024-04-25 10:38:00 -07:00
morph_tls.c Release Cosmopolitan v3.3 2024-02-20 13:27:59 -08:00
openexecutable.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
opensymboltable.greg.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
pathconf.h Reduce header complexity 2023-11-28 14:39:42 -08:00
pc.internal.h Run clang-format (#1197) 2024-06-01 16:30:43 -04:00
printgarbage.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
progname.S Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
pthread_keys.c Introduce ctl::set and ctl::map 2024-06-23 22:27:11 -07:00
quick_exit.c Add C++ demangling to privileged runtime 2024-06-01 20:10:58 -07:00
runtime.h Fix fork() crash on Windows 2024-10-12 15:38:58 -07:00
set_tls.c Add back missing TlsAlloc() call 2024-07-21 20:45:27 -07:00
sigsetjmp.S Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
stack.h Avoid an --ftrace crash on Windows 2024-10-07 18:39:25 -07:00
straceinit.greg.c Share file offset across execve() on Windows 2024-08-03 17:48:00 -07:00
symbols.c Delete ASAN 2024-06-22 05:45:49 -07:00
symbols.internal.h Reduce header complexity 2023-11-28 14:39:42 -08:00
sysconf.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
sysconf.h Make realloc() go 100x faster on Linux/NetBSD 2024-07-07 12:40:30 -07:00
syslib.internal.h Make malloc scalable on all platforms 2024-08-15 23:32:53 -07:00
utmp.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
utmp.h Reduce header complexity 2023-11-28 14:39:42 -08:00
utmpx.h Reduce header complexity 2023-11-28 14:39:42 -08:00
valist.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
warnifpowersave.c Restore support for AMD K8 2024-07-24 08:59:29 -07:00
weakfree.c Graduate some clock_gettime() constants to #define 2024-07-22 07:14:35 -07:00
winargs.internal.h Make improvements 2024-02-12 10:23:00 -08:00
winmain.greg.c Improve Windows mode bits 2024-09-22 16:51:57 -07:00
zipos-access.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
zipos-close.c Rename __zipos_free -> __zipos_drop (#1043) 2023-12-26 12:08:57 -05:00
zipos-fcntl.c Run clang-format (#1197) 2024-06-01 16:30:43 -04:00
zipos-find.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
zipos-fstat.c Apply clang-format update to repo (#1154) 2024-04-25 10:38:00 -07:00
zipos-get.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
zipos-inode.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
zipos-mmap.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
zipos-normpath.c Apply clang-format update to repo (#1154) 2024-04-25 10:38:00 -07:00
zipos-notat.c Add missing ICANON features 2024-09-05 03:17:19 -07:00
zipos-open.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
zipos-parseuri.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
zipos-read.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
zipos-seek.c Skip the CAS on new_pos < 0 (#1080) 2024-01-12 21:08:28 -08:00
zipos-stat-impl.c Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00
zipos-stat.c Apply clang-format update to repo (#1154) 2024-04-25 10:38:00 -07:00
zipos.internal.h Remove bad defines from early days of project 2024-07-24 12:11:21 -07:00
zipos.S Remove .internal from more header filenames 2024-08-04 12:52:25 -07:00