mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-12 05:59:10 +00:00
Rewrite memory manager
Actually Portable Executable now supports Android. Cosmo's old mmap code required a 47 bit address space. The new implementation is very agnostic and supports both smaller address spaces (e.g. embedded) and even modern 56-bit PML5T paging for x86 which finally came true on Zen4 Threadripper Cosmopolitan no longer requires UNIX systems to observe the Windows 64kb granularity; i.e. sysconf(_SC_PAGE_SIZE) will now report the host native page size. This fixes a longstanding POSIX conformance issue, concerning file mappings that overlap the end of file. Other aspects of conformance have been improved too, such as the subtleties of address assignment and and the various subtleties surrounding MAP_FIXED and MAP_FIXED_NOREPLACE On Windows, mappings larger than 100 megabytes won't be broken down into thousands of independent 64kb mappings. Support for MAP_STACK is removed by this change; please use NewCosmoStack() instead. Stack overflow avoidance is now being implemented using the POSIX thread APIs. Please use GetStackBottom() and GetStackAddr(), instead of the old error-prone GetStackAddr() and HaveStackMemory() APIs which are removed.
This commit is contained in:
parent
7f6d0b8709
commit
6ffed14b9c
150 changed files with 1893 additions and 5634 deletions
|
@ -1,19 +1,9 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_LOG_BACKTRACE_H_
|
||||
#define COSMOPOLITAN_LIBC_LOG_BACKTRACE_H_
|
||||
#include "libc/nexgen32e/stackframe.h"
|
||||
#include "libc/runtime/memtrack.internal.h"
|
||||
#include "libc/runtime/symbols.internal.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
forceinline pureconst bool IsValidStackFramePointer(struct StackFrame *x) {
|
||||
/* assumes __mmi_lock() is held */
|
||||
return IsLegalPointer(x) && !((uintptr_t)x & 15) &&
|
||||
(IsStaticStackFrame((uintptr_t)x >> 16) ||
|
||||
IsOldStackFrame((uintptr_t)x >> 16) ||
|
||||
/* lua coroutines need this */
|
||||
IsMemtracked((uintptr_t)x >> 16, (uintptr_t)x >> 16));
|
||||
}
|
||||
|
||||
void ShowBacktrace(int, const struct StackFrame *);
|
||||
int PrintBacktraceUsingSymbols(int, const struct StackFrame *,
|
||||
struct SymbolTable *);
|
||||
|
|
|
@ -126,7 +126,6 @@ dontasan void CheckForMemoryLeaks(void) {
|
|||
malloc_inspect_all(OnMemory, 0);
|
||||
kprintf("\n");
|
||||
/* __print_maps(); */
|
||||
/* PrintSystemMappings(2); */
|
||||
/* PrintGarbage(); */
|
||||
_Exit(78);
|
||||
}
|
||||
|
|
|
@ -245,7 +245,6 @@ static relegated void ShowCrashReport(int err, int sig, siginfo_t *si,
|
|||
if (!IsWindows()) {
|
||||
__print_maps();
|
||||
}
|
||||
/* PrintSystemMappings(2); */
|
||||
if (__argv) {
|
||||
for (i = 0; i < __argc; ++i) {
|
||||
kprintf("%s ", __argv[i]);
|
||||
|
@ -269,6 +268,8 @@ static inline void SpinUnlock(atomic_uint *lock) {
|
|||
|
||||
relegated void __oncrash(int sig, siginfo_t *si, void *arg) {
|
||||
static atomic_uint lock;
|
||||
ftrace_enabled(-1);
|
||||
strace_enabled(-1);
|
||||
BLOCK_CANCELATION;
|
||||
SpinLock(&lock);
|
||||
int err = errno;
|
||||
|
@ -291,6 +292,8 @@ relegated void __oncrash(int sig, siginfo_t *si, void *arg) {
|
|||
|
||||
SpinUnlock(&lock);
|
||||
ALLOW_CANCELATION;
|
||||
strace_enabled(+1);
|
||||
ftrace_enabled(+1);
|
||||
}
|
||||
|
||||
#endif /* __x86_64__ */
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "libc/calls/ucontext.h"
|
||||
#include "libc/cosmo.h"
|
||||
#include "libc/cxxabi.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/intrin/atomic.h"
|
||||
#include "libc/intrin/describebacktrace.internal.h"
|
||||
|
@ -211,8 +212,6 @@ static relegated void __oncrash_impl(int sig, siginfo_t *si, ucontext_t *ctx) {
|
|||
struct utsname names = {0};
|
||||
struct Buffer b[1] = {{buf, size}};
|
||||
b->p[b->i++] = '\n';
|
||||
ftrace_enabled(-1);
|
||||
strace_enabled(-1);
|
||||
__restore_tty();
|
||||
uname(&names);
|
||||
gethostname(host, sizeof(host));
|
||||
|
@ -390,6 +389,8 @@ static inline void SpinUnlock(atomic_uint *lock) {
|
|||
|
||||
relegated void __oncrash(int sig, siginfo_t *si, void *arg) {
|
||||
static atomic_uint lock;
|
||||
ftrace_enabled(-1);
|
||||
strace_enabled(-1);
|
||||
BLOCK_CANCELATION;
|
||||
SpinLock(&lock);
|
||||
__oncrash_impl(sig, si, arg);
|
||||
|
@ -416,6 +417,8 @@ relegated void __oncrash(int sig, siginfo_t *si, void *arg) {
|
|||
|
||||
SpinUnlock(&lock);
|
||||
ALLOW_CANCELATION;
|
||||
strace_enabled(+1);
|
||||
ftrace_enabled(+1);
|
||||
}
|
||||
|
||||
#endif /* __aarch64__ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue