Snapshot for release 2026.10.15.6 (internal 6fd9478)
This commit is contained in:
parent
aba17a9834
commit
a57049d931
44 changed files with 12244 additions and 10674 deletions
|
|
@ -37,11 +37,12 @@
|
|||
#define STAGING_SUBDIR ".engine_loads"
|
||||
// Hot reloads one client takes before it refuses the rest (until it restarts). The engine
|
||||
// says the real number (engine.json MaxHotReloads, RynthCoreMaxHotReloads export); this is
|
||||
// for an engine without the export. After 4+ reloads in one process, clients died with
|
||||
// CoreCLR fatal error 0x80131506 at coreclr+0x256E19 (2026-10-08..10, gens 5-6 or the 4th
|
||||
// reload itself) although every generation unloaded and address space stayed flat: treated
|
||||
// as a CoreCLR limit on repeated collectible loads, so the loader stops short of it.
|
||||
#define DEFAULT_MAX_HOT_RELOADS 3
|
||||
// for an engine without the export. 3 from 2026-10-11, after clients died with CoreCLR fatal
|
||||
// error 0x80131506 at coreclr+0x256E19 after 4+ reloads in one process (2026-10-08..10). The
|
||||
// 10-15 dump triage put those on the v1 SehTrampoline crash logger (ReversePInvokeBadTransition,
|
||||
// fixed by db645ba on 10-12), not on reloading: none since, and address space was healthy at
|
||||
// every crash. So 20 since 2026-10-15: a backstop, not a known CoreCLR limit.
|
||||
#define DEFAULT_MAX_HOT_RELOADS 20
|
||||
// CoreCLR's own crash dump (createdump.exe, DOTNET_DbgEnableMiniDump): clr_<pid>_<time>.dmp
|
||||
// in Logs\dumps, newest DUMP_KEEP kept. With the heap (type 2) only while the volume keeps
|
||||
// DUMP_HEAP_MIN_FREE_MB free (a heap dump of a client is ~1 GB); else a normal one (stacks).
|
||||
|
|
@ -54,6 +55,10 @@
|
|||
// room for one more generation; the NativeAOT engine leaks every generation.
|
||||
#define MIN_FREE_MB_AOT 1200
|
||||
#define MIN_FREE_MB_CLR 500
|
||||
// ...and (CoreCLR, 2026-10-15) one free block that size: the new generation's images and the
|
||||
// GC's segments each need a contiguous range, so a fragmented space can fail a reload that
|
||||
// the free total allows. Every crash triaged 10-15 still had >= 1.6 GB in one block.
|
||||
#define MIN_LARGEST_MB_CLR 400
|
||||
|
||||
typedef unsigned int (__stdcall *engine_u32_fn)(void* param);
|
||||
typedef unsigned int (__stdcall *engine_refused_fn)(int freeMb);
|
||||
|
|
@ -137,6 +142,16 @@ long LoaderFreeAddressSpaceMb(long* largestMb)
|
|||
return (long)(total / (1024 * 1024));
|
||||
}
|
||||
|
||||
// Why a hot reload would be refused for address space (LoaderFreeAddressSpaceMb's figures):
|
||||
// 0 = room for it, 1 = too little free in all, 2 = a CoreCLR engine with enough free in all but
|
||||
// no single free block of MIN_LARGEST_MB_CLR.
|
||||
static int ReloadSpaceShort(int managed, long freeMb, long largestMb)
|
||||
{
|
||||
if (freeMb < (managed ? MIN_FREE_MB_CLR : MIN_FREE_MB_AOT)) return 1;
|
||||
if (managed && largestMb < MIN_LARGEST_MB_CLR) return 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Engine file: staging and kind
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
@ -490,7 +505,7 @@ static DWORD WINAPI ReloadWatcher(LPVOID unused)
|
|||
if (ReloadCapReached(reloadsDone, cap)) {
|
||||
LoaderLog("WRN", "ReloadWatcher: reload REFUSED - this client has hot reloaded %d time(s), the cap "
|
||||
"(engine.json MaxHotReloads) is %d. Staying on engine gen %d; restart the client to load the "
|
||||
"new engine. (Repeated hot reloads in one client ended in CoreCLR fatal error 0x80131506.)",
|
||||
"new engine. (The cap is a backstop against piling up hot reloads in one client.)",
|
||||
reloadsDone, cap, g_initCount);
|
||||
engine_capped_fn capped = (engine_capped_fn)EngineExport(ENGINE_CAPPED_EXPORT);
|
||||
if (capped) capped(reloadsDone, cap);
|
||||
|
|
@ -498,12 +513,20 @@ static DWORD WINAPI ReloadWatcher(LPVOID unused)
|
|||
}
|
||||
|
||||
long minFree = g_engineIsManaged ? MIN_FREE_MB_CLR : MIN_FREE_MB_AOT;
|
||||
long freeMb = LoaderFreeAddressSpaceMb(NULL);
|
||||
if (freeMb < minFree) {
|
||||
long largestMb;
|
||||
long freeMb = LoaderFreeAddressSpaceMb(&largestMb);
|
||||
int shortOf = ReloadSpaceShort(g_engineIsManaged, freeMb, largestMb);
|
||||
if (shortOf == 1)
|
||||
LoaderLog("WRN", "ReloadWatcher: reload REFUSED - only %ld MB of address space free (need %ld MB). "
|
||||
"Restart the client to load the new engine.", freeMb, minFree);
|
||||
else if (shortOf == 2)
|
||||
LoaderLog("WRN", "ReloadWatcher: reload REFUSED - the largest free block of address space is only %ld MB "
|
||||
"(need %ld MB; %ld MB free in all). Restart the client to load the new engine.",
|
||||
largestMb, (long)MIN_LARGEST_MB_CLR, freeMb);
|
||||
if (shortOf) {
|
||||
// The engine is told the figure that fell short; it says so in chat.
|
||||
engine_refused_fn refused = (engine_refused_fn)EngineExport(ENGINE_REFUSED_EXPORT);
|
||||
if (refused) refused((int)freeMb);
|
||||
if (refused) refused((int)(shortOf == 1 ? freeMb : largestMb));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,9 @@
|
|||
#include <windows.h>
|
||||
|
||||
/* File version of this native module (bump with every behavioural change). */
|
||||
#define RC_SEH_TRAMPOLINE_VERSION 6 /* v6: AwfulWaffle's crash logger (per-address dedupe, pid/date,
|
||||
#define RC_SEH_TRAMPOLINE_VERSION 7 /* v7: stack sweeps bounded by this thread's stack (TEB), never
|
||||
reading at or past StackBase;
|
||||
v6: AwfulWaffle's crash logger (per-address dedupe, pid/date,
|
||||
flush ring, RC_FlushCrashLog, module cache) merged with v3-v5;
|
||||
v5: crash log handle opened once at install; no CreateFileW
|
||||
while an exception is being dispatched */
|
||||
|
|
@ -502,14 +504,34 @@ static char* cl_sym(char* p, unsigned int addr, int allowFallback)
|
|||
return p;
|
||||
}
|
||||
|
||||
/*
|
||||
* How many 32-bit words a stack read starting at esp may take on THIS thread (at most
|
||||
* maxWords): up to the thread's stack base, never at or past it. 0 when esp is not on this
|
||||
* thread's stack ([StackLimit, StackBase) from the TEB; no API call). The handlers run on
|
||||
* the faulting thread, so the context's esp is on this stack. v7: before, the sweeps read a
|
||||
* fixed count and relied on the fault past the stack top to stop them; a 2026-10-15 dump
|
||||
* showed the sweep reading 0x12BF0000 (the stack base) inside CoreCLR's fatal path.
|
||||
*/
|
||||
static unsigned int cl_stack_words(unsigned int esp, unsigned int maxWords)
|
||||
{
|
||||
NT_TIB* tib = (NT_TIB*)NtCurrentTeb();
|
||||
unsigned int base = (unsigned int)(UINT_PTR)tib->StackBase;
|
||||
unsigned int limit = (unsigned int)(UINT_PTR)tib->StackLimit;
|
||||
unsigned int words;
|
||||
if (esp < limit || esp >= base) return 0;
|
||||
words = (base - esp) / 4; /* the last word read ends at or below base */
|
||||
return words < maxWords ? words : maxWords;
|
||||
}
|
||||
|
||||
/* Class of the nearest cached-module code pointer on the stack (AC if none found). */
|
||||
static clf_class cl_first_frame_class(unsigned int esp)
|
||||
{
|
||||
clf_class result = CLF_CLASS_AC;
|
||||
unsigned int words = cl_stack_words(esp, 512);
|
||||
__try {
|
||||
unsigned int* sp = (unsigned int*)(UINT_PTR)esp;
|
||||
int i;
|
||||
for (i = 0; i < 512; i++) {
|
||||
unsigned int i;
|
||||
for (i = 0; i < words; i++) {
|
||||
unsigned int v = sp[i];
|
||||
const cl_mod* m;
|
||||
if (v <= 0x00401000u || v >= 0x7FFF0000u) continue;
|
||||
|
|
@ -553,6 +575,7 @@ static void cl_write_entry(PEXCEPTION_POINTERS ep, const char* kind, unsigned in
|
|||
CONTEXT* c = ep->ContextRecord;
|
||||
DWORD code = ep->ExceptionRecord->ExceptionCode;
|
||||
unsigned int exAddr = (unsigned int)(UINT_PTR)ep->ExceptionRecord->ExceptionAddress;
|
||||
unsigned int words;
|
||||
if (g_logHandle == INVALID_HANDLE_VALUE) return;
|
||||
|
||||
p = cl_str(p, "\r\n==== NATIVE CRASH LOGGER (");
|
||||
|
|
@ -593,10 +616,16 @@ static void cl_write_entry(PEXCEPTION_POINTERS ep, const char* kind, unsigned in
|
|||
p = cl_str(p, "\r\n stack code pointers (esp -> up):\r\n");
|
||||
cl_write(g_buf, (DWORD)(p - g_buf));
|
||||
|
||||
words = cl_stack_words(c->Esp, 4096);
|
||||
if (words == 0) {
|
||||
const char* m = " <esp is not on this thread's stack; no sweep>\r\n";
|
||||
cl_write(m, (DWORD)lstrlenA(m));
|
||||
}
|
||||
__try {
|
||||
unsigned int* sp = (unsigned int*)(UINT_PTR)c->Esp;
|
||||
int i, emitted = 0;
|
||||
for (i = 0; i < 4096 && emitted < 96; i++) {
|
||||
unsigned int i;
|
||||
int emitted = 0;
|
||||
for (i = 0; i < words && emitted < 96; i++) {
|
||||
unsigned int v = sp[i];
|
||||
if (v > 0x00401000u && v < 0x7FFF0000u && cl_mod_cached(v)) {
|
||||
char* q = g_buf;
|
||||
|
|
|
|||
Loading…
Reference in a new issue