From 5f08a6cbeff5a9050a67e616ed8feb35ab2f96e1 Mon Sep 17 00:00:00 2001 From: Sosuke Suzuki Date: Tue, 24 Feb 2026 12:08:53 +0900 Subject: [PATCH 1/2] Make RELEASE_ASSERT call Bun__panic for Sentry crash reporting CRASH_WITH_INFO macro now calls Bun__panic with file, line, and function info when USE(BUN_JSC_ADDITIONS) is enabled. This ensures RELEASE_ASSERT failures are reported to Sentry with full context instead of silently crashing via breakpoint trap. --- Source/WTF/wtf/Assertions.cpp | 15 +++++++++++++++ Source/WTF/wtf/Assertions.h | 12 ++++++++++++ Source/cmake/WebKitCompilerFlags.cmake | 6 ++++-- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/Source/WTF/wtf/Assertions.cpp b/Source/WTF/wtf/Assertions.cpp index 991f99673767..482a04f4aac8 100644 --- a/Source/WTF/wtf/Assertions.cpp +++ b/Source/WTF/wtf/Assertions.cpp @@ -653,6 +653,21 @@ void WTFInitializeLogChannelStatesFromString(WTFLogChannel* channels[], size_t c } // extern "C" +#if USE(BUN_JSC_ADDITIONS) + +extern "C" void __attribute__((__noreturn__)) Bun__panic(const char* message, size_t length); + +void bunPanicFromCrash(const char* file, int line, const char* function) +{ + char buf[1024]; + int len = snprintf(buf, sizeof(buf), "RELEASE_ASSERT in %s at %s:%d", function, file, line); + if (len < 0 || len >= static_cast(sizeof(buf))) + len = sizeof(buf) - 1; + Bun__panic(buf, static_cast(len)); +} + +#endif // USE(BUN_JSC_ADDITIONS) + #if !ASAN_ENABLED && (OS(DARWIN) || PLATFORM(PLAYSTATION)) && (CPU(X86_64) || CPU(ARM64)) void WTFCrashWithInfoImpl(int, const char*, const char*, uint64_t reason, uint64_t misc1, uint64_t misc2, uint64_t misc3, uint64_t misc4, uint64_t misc5, uint64_t misc6) diff --git a/Source/WTF/wtf/Assertions.h b/Source/WTF/wtf/Assertions.h index 58122e8c9c1e..dc8b9aba2272 100644 --- a/Source/WTF/wtf/Assertions.h +++ b/Source/WTF/wtf/Assertions.h @@ -1012,6 +1012,16 @@ inline void compilerFenceForCrash() #ifndef CRASH_WITH_INFO +#if USE(BUN_JSC_ADDITIONS) + +WTF_EXPORT_PRIVATE NO_RETURN_DUE_TO_CRASH void bunPanicFromCrash(const char* file, int line, const char* function); + +#define CRASH_WITH_INFO(...) do { \ + bunPanicFromCrash(__FILE__, __LINE__, WTF_PRETTY_FUNCTION); \ + } while (false) + +#else + #define PP_THIRD_ARG(a,b,c,...) c #define VA_OPT_SUPPORTED_I(...) PP_THIRD_ARG(__VA_OPT__(,),true,false,) #define VA_OPT_SUPPORTED VA_OPT_SUPPORTED_I(?) @@ -1031,6 +1041,8 @@ inline void compilerFenceForCrash() WTFCrashWithInfo(__LINE__, __FILE__, WTF_PRETTY_FUNCTION __VA_OPT__(,) __VA_ARGS__); \ } while (false) #endif + +#endif // USE(BUN_JSC_ADDITIONS) #endif // CRASH_WITH_INFO #ifndef CRASH_WITH_SECURITY_IMPLICATION_AND_INFO diff --git a/Source/cmake/WebKitCompilerFlags.cmake b/Source/cmake/WebKitCompilerFlags.cmake index c94cb1924ac5..240dc385e2ec 100644 --- a/Source/cmake/WebKitCompilerFlags.cmake +++ b/Source/cmake/WebKitCompilerFlags.cmake @@ -265,7 +265,8 @@ if (COMPILER_IS_GCC_OR_CLANG) -Wl,-U,_WTFTimer__secondsUntilTimer -Wl,-U,_WTFTimer__cancel -Wl,-U,_Bun__errorInstance__finalize - -Wl,-U,_Bun__reportUnhandledError) + -Wl,-U,_Bun__reportUnhandledError + -Wl,-U,_Bun__panic) else() WEBKIT_PREPEND_GLOBAL_COMPILER_FLAGS(-Wl,-u,_WTFTimer__create -Wl,-u,_WTFTimer__update @@ -274,7 +275,8 @@ if (COMPILER_IS_GCC_OR_CLANG) -Wl,-u,_WTFTimer__secondsUntilTimer -Wl,-u,_WTFTimer__cancel -Wl,-u,_Bun__errorInstance__finalize - -Wl,-u,_Bun__reportUnhandledError) + -Wl,-u,_Bun__reportUnhandledError + -Wl,-u,_Bun__panic) endif() endif () From bb31db9e4a3daea284c3c72437711a47ad8d596d Mon Sep 17 00:00:00 2001 From: Sosuke Suzuki Date: Tue, 24 Feb 2026 14:49:50 +0900 Subject: [PATCH 2/2] Fix CI: weak Bun__panic fallback and move VA_OPT_SUPPORTED definition - Move VA_OPT_SUPPORTED macro definition outside #ifndef CRASH_WITH_INFO so it's always defined even when USE(BUN_JSC_ADDITIONS) is enabled. Fixes compile error in Integrity.h on Windows. - Make Bun__panic a weak symbol with CRASH() fallback so the jsc standalone binary can link without Bun's runtime. Fixes link errors on Linux musl and Linux ARM64 ASAN. --- Source/WTF/wtf/Assertions.cpp | 9 ++++++++- Source/WTF/wtf/Assertions.h | 8 ++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Source/WTF/wtf/Assertions.cpp b/Source/WTF/wtf/Assertions.cpp index 482a04f4aac8..a0d2118045e4 100644 --- a/Source/WTF/wtf/Assertions.cpp +++ b/Source/WTF/wtf/Assertions.cpp @@ -655,7 +655,13 @@ void WTFInitializeLogChannelStatesFromString(WTFLogChannel* channels[], size_t c #if USE(BUN_JSC_ADDITIONS) -extern "C" void __attribute__((__noreturn__)) Bun__panic(const char* message, size_t length); +#if COMPILER(MSVC) +extern "C" void Bun__panicFallback(const char*, size_t) { CRASH(); } +extern "C" void Bun__panic(const char* message, size_t length); +#pragma comment(linker, "/alternatename:Bun__panic=Bun__panicFallback") +#else +extern "C" __attribute__((__weak__)) void Bun__panic(const char* message, size_t length) { CRASH(); } +#endif void bunPanicFromCrash(const char* file, int line, const char* function) { @@ -664,6 +670,7 @@ void bunPanicFromCrash(const char* file, int line, const char* function) if (len < 0 || len >= static_cast(sizeof(buf))) len = sizeof(buf) - 1; Bun__panic(buf, static_cast(len)); + CRASH(); } #endif // USE(BUN_JSC_ADDITIONS) diff --git a/Source/WTF/wtf/Assertions.h b/Source/WTF/wtf/Assertions.h index dc8b9aba2272..1bac530440f0 100644 --- a/Source/WTF/wtf/Assertions.h +++ b/Source/WTF/wtf/Assertions.h @@ -1010,6 +1010,10 @@ inline void compilerFenceForCrash() asm volatile("" ::: "memory"); } +#define PP_THIRD_ARG(a,b,c,...) c +#define VA_OPT_SUPPORTED_I(...) PP_THIRD_ARG(__VA_OPT__(,),true,false,) +#define VA_OPT_SUPPORTED VA_OPT_SUPPORTED_I(?) + #ifndef CRASH_WITH_INFO #if USE(BUN_JSC_ADDITIONS) @@ -1022,10 +1026,6 @@ WTF_EXPORT_PRIVATE NO_RETURN_DUE_TO_CRASH void bunPanicFromCrash(const char* fil #else -#define PP_THIRD_ARG(a,b,c,...) c -#define VA_OPT_SUPPORTED_I(...) PP_THIRD_ARG(__VA_OPT__(,),true,false,) -#define VA_OPT_SUPPORTED VA_OPT_SUPPORTED_I(?) - // This is useful if you are going to stuff data into registers before crashing, like the // crashWithInfo functions below. #if !VA_OPT_SUPPORTED