From bb654470b2990b2d2dd88ecfc4c4f58426552545 Mon Sep 17 00:00:00 2001 From: Tobim6 <102646588+Tobim6@users.noreply.github.com> Date: Thu, 12 Nov 2026 16:22:24 +0100 Subject: [PATCH] Crash report: the log names what the crashing thread was building, and a library link names its case. Co-Authored-By: Claude Opus 5.5 --- runtime/main.c | 3 +++ runtime/platform/linux.c | 1 + runtime/platform/platform.h | 1 + runtime/platform/win32.c | 1 + runtime/vk_pipeline.c | 15 +++++++++++---- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/runtime/main.c b/runtime/main.c index 9e376322..a6e67e07 100644 --- a/runtime/main.c +++ b/runtime/main.c @@ -291,6 +291,9 @@ static void crash_handler(const PlatCrash *x) { if (foreign_hook(x->module)) rt_logf(" %s is not part of the game: a recording, overlay or capture program put it into the game. Close that " "program or turn off its Vulkan capture, then start the game again\n", x->module); + // what the thread was doing (a pipeline build names its shaders): the stderr note crash_veh writes misses the log + const char *note = plat_crash_context_get(); + if (note) rt_logf(" the thread was %s\n", note); uint64_t f = x->module ? 0 : lifted_function(rip); if (f) rt_logf(" in lifted function f_%llx = %s\n", (unsigned long long)f, ldr_describe(f, d, sizeof d)); // abort and invalid parameter: where the host code called it; a fault in another module: the host calls that led diff --git a/runtime/platform/linux.c b/runtime/platform/linux.c index da703894..8c531f28 100644 --- a/runtime/platform/linux.c +++ b/runtime/platform/linux.c @@ -1294,6 +1294,7 @@ void plat_mem_access_hook(int (*fn)(uint64_t addr, int write, uint64_t ip)) { void plat_crash_context(const char *s) { (void)s; } // the Windows crash notes only int plat_crash_filter_reassert(char *who, size_t n) { (void)who, (void)n; return 0; } // Windows only +const char *plat_crash_context_get(void) { return NULL; } // plat_jmp_save / plat_jmp_go (platform.h): leaf code that does not move rsp before it leaves, as on Windows. _Static_assert(sizeof(PlatJmp) == 72 && __builtin_offsetof(PlatJmp, mxcsr) == 64, "plat_jmp_save layout"); diff --git a/runtime/platform/platform.h b/runtime/platform/platform.h index 0722cf08..64c0b056 100644 --- a/runtime/platform/platform.h +++ b/runtime/platform/platform.h @@ -296,6 +296,7 @@ void plat_crash_context(const char *s); // Puts the crash hook's last-chance exception filter back in place. 1 when a DLL loaded later had set its own in its // place (who: that filter's module and offset), 0 when it was still there. Windows only; 0 elsewhere. int plat_crash_filter_reassert(char *who, size_t n); +const char *plat_crash_context_get(void); // the calling thread's note, for the crash report (NULL: none) int plat_mem_read(uint64_t addr, void *out, size_t n); // copies n bytes, 0 instead of faulting on unmapped memory int plat_mem_readable(uint64_t addr, uint64_t n); // every page of [addr, addr + n) can be read; no fault void *plat_aligned_alloc(size_t size, size_t align); // free with plat_aligned_free; NULL on failure diff --git a/runtime/platform/win32.c b/runtime/platform/win32.c index fa742a84..cfaa5c9e 100644 --- a/runtime/platform/win32.c +++ b/runtime/platform/win32.c @@ -908,6 +908,7 @@ static void (*crash_fn)(const PlatCrash *c); static const char *image_name(const char *base); static __thread const char *crash_ctx; void plat_crash_context(const char *s) { crash_ctx = s; } +const char *plat_crash_context_get(void) { return crash_ctx; } static void raw_note(const char *tag, DWORD code, uintptr_t rip, uintptr_t addr) { char b[256]; void *base = NULL; diff --git a/runtime/vk_pipeline.c b/runtime/vk_pipeline.c index ef7c32f5..2fc476ce 100644 --- a/runtime/vk_pipeline.c +++ b/runtime/vk_pipeline.c @@ -2495,9 +2495,9 @@ static const char *origin_name(const GfxShader *s) { // The shaders of the pipeline this thread builds, for the crash notes (platform.h plat_crash_context): the first 8 // bytes of each cache key, as gfx_shader.c names its cache files. static void crash_note(const char *what, const GfxShader *a, const GfxShader *b, const GfxShader *c) { - static __thread char buf[160]; + static __thread char buf[320]; char *o = buf; - o += snprintf(o, 40, "building %s", what); + o += snprintf(o, 160, "building %s", what); const GfxShader *sh[3] = {a, b, c}; for (int i = 0; i < 3; i++) if (sh[i]) { @@ -3607,7 +3607,9 @@ static VkPipeline lib_create(int kind, const VkPipeState *s, const GKey *k, VkPi VkPipelineCreationFeedbackCreateInfo fci; VkPipelineCreationFeedback fb; pi.pNext = fb_chain(&fci, &fb, pi.pNext); - crash_note("a pipeline library", s->vs, s->fs, NULL); + static const char *const kind_name[4] = {"a vertex input library", "a pre-rasterization library", + "a fragment shader library", "a fragment output library"}; + crash_note(kind_name[kind], s->vs, s->fs, NULL); if (pipe_create(1, &pi, &pipe) != VK_SUCCESS) pipe = VK_NULL_HANDLE; plat_crash_context(NULL); if (pipe && (kind == LIB_PR || kind == LIB_FS)) fb_note(FB_LIBRARY, &fb); // the shader libraries: the others compile nothing @@ -3838,7 +3840,12 @@ static VkPipeline gpl_link(const VkPipeState *s, const GKey *k, const Layout *lc .layout = l->layout}; if (build) plat_mutex_unlock(&P.lock); uint64_t t1 = qpc(); - crash_note("a library link", s->vs, s->fs, NULL); + char what[160]; // the parts that differ between links: a link that crashes the driver names its case + snprintf(what, sizeof what, + "a library link (fragment shader %s, %u colour targets, depth format %u, stencil format %u, %u samples, " + "vertex outputs added %#x)", s->fs ? "yes" : "none", k->n_color, k->depth, k->stencil, k->samples, + pk.missing); + crash_note(what, s->vs, s->fs, NULL); if (vkCreateGraphicsPipelines(P.device, VK_NULL_HANDLE, 1, &pi, NULL, &pipe) != VK_SUCCESS) pipe = VK_NULL_HANDLE; plat_crash_context(NULL); double ms = ms_since(t1); // the link alone: library builds are counted apart