Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Source/WTF/wtf/Assertions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,28 @@ void WTFInitializeLogChannelStatesFromString(WTFLogChannel* channels[], size_t c

} // extern "C"

#if USE(BUN_JSC_ADDITIONS)

#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)
{
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<int>(sizeof(buf)))
len = sizeof(buf) - 1;
Bun__panic(buf, static_cast<size_t>(len));
CRASH();
}

#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)
Expand Down
16 changes: 14 additions & 2 deletions Source/WTF/wtf/Assertions.h
Original file line number Diff line number Diff line change
Expand Up @@ -1010,12 +1010,22 @@ inline void compilerFenceForCrash()
asm volatile("" ::: "memory");
}

#ifndef CRASH_WITH_INFO

#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)

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

// This is useful if you are going to stuff data into registers before crashing, like the
// crashWithInfo functions below.
#if !VA_OPT_SUPPORTED
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions Source/cmake/WebKitCompilerFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 ()

Expand Down
Loading