Skip to content

Make RELEASE_ASSERT use Bun__panic for crash reporting#167

Open
sosukesuzuki wants to merge 2 commits intomainfrom
claude/release-assert-bun-panic
Open

Make RELEASE_ASSERT use Bun__panic for crash reporting#167
sosukesuzuki wants to merge 2 commits intomainfrom
claude/release-assert-bun-panic

Conversation

@sosukesuzuki
Copy link

When USE(BUN_JSC_ADDITIONS) is enabled, CRASH_WITH_INFO now calls Bun__panic instead of using a breakpoint trap. This means RELEASE_ASSERT failures go through Bun's crash handler, which provides:

  • A descriptive panic message with the function name, file, and line number
  • A full stack trace

Changes

  • Assertions.h: Redefine CRASH_WITH_INFO for BUN_JSC_ADDITIONS to call bunPanicFromCrash()
  • Assertions.cpp: Implement bunPanicFromCrash() which formats a message and calls Bun__panic
  • WebKitCompilerFlags.cmake: Add linker flags for Bun__panic symbol

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.
@coderabbitai
Copy link

coderabbitai bot commented Feb 24, 2026

Walkthrough

Adds Bun-specific panic support: declares extern Bun__panic, implements bunPanicFromCrash in Assertions.cpp, changes CRASH_WITH_INFO to call that helper under USE(BUN_JSC_ADDITIONS), and updates linker flags to require Bun__panic as an unresolved symbol.

Changes

Cohort / File(s) Summary
Panic Handler Functions
Source/WTF/wtf/Assertions.cpp, Source/WTF/wtf/Assertions.h
Adds extern "C" void Bun__panic(const char*, size_t); and void bunPanicFromCrash(const char* file, int line, const char* function); guarded by #if USE(BUN_JSC_ADDITIONS). Implements platform-specific Bun__panic linkage behavior (MSVC alias or weak symbol) and bunPanicFromCrash that formats a message and calls Bun__panic, then CRASH(). Replaces CRASH_WITH_INFO to call bunPanicFromCrash when the feature is enabled; retains original macro for other builds.
Linker Configuration
Source/cmake/WebKitCompilerFlags.cmake
Appends unresolved-symbol flags for Bun__panic alongside existing Bun__reportUnhandledError: -Wl,-U,_Bun__panic on Apple paths and -Wl,-u,_Bun__panic on non-Apple paths.
🚥 Pre-merge checks | ✅ 1 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description lacks the required Bugzilla bug reference, reviewer acknowledgment, and proper template structure expected by the WebKit project. Add a Bugzilla bug link at the top, include 'Reviewed by NOBODY (OOPS!)' section, and format description as a commit message following the WebKit template.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely summarizes the main change: making RELEASE_ASSERT use Bun__panic for crash reporting.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Source/WTF/wtf/Assertions.h`:
- Around line 1019-1022: The BUN macro CRASH_WITH_INFO currently discards
__VA_ARGS__ and omits the type check, so restore the compile-time guard by
invoking WTF::isIntegralOrPointerType(__VA_ARGS__) (or an equivalent
static_assert/type-trait expression) inside the macro while still not using the
values — for example evaluate the trait in a void-cast or unused constexpr to
force the type-check and then call bunPanicFromCrash(__FILE__, __LINE__,
WTF_PRETTY_FUNCTION); ensure the macro name CRASH_WITH_INFO and the
bunPanicFromCrash call remain unchanged and that only the type-check expression
referencing __VA_ARGS__ is added so non-integral/non-pointer arguments cause a
compile error.

ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 1f22e5d and 5f08a6c.

📒 Files selected for processing (3)
  • Source/WTF/wtf/Assertions.cpp
  • Source/WTF/wtf/Assertions.h
  • Source/cmake/WebKitCompilerFlags.cmake

Comment on lines +1019 to +1022
#define CRASH_WITH_INFO(...) do { \
bunPanicFromCrash(__FILE__, __LINE__, WTF_PRETTY_FUNCTION); \
} while (false)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

BUN path silently discards ... args and drops the isIntegralOrPointerType type guard.

The non-BUN CRASH_WITH_INFO calls WTF::isIntegralOrPointerType(__VA_ARGS__) before crashing, which produces a hard compile error if a caller passes a non-integral/non-pointer type. The BUN path accepts any args without type-checking and silently ignores them. Code written in a BUN-only build environment that passes wrong-typed values to CRASH_WITH_INFO will compile cleanly but break non-BUN builds, making it a potential CI blind spot.

Consider preserving the guard even though the values themselves are intentionally dropped:

🛡️ Proposed fix – retain type guard
 `#define` CRASH_WITH_INFO(...) do { \
+        WTF::isIntegralOrPointerType(__VA_ARGS__); \
         bunPanicFromCrash(__FILE__, __LINE__, WTF_PRETTY_FUNCTION); \
     } while (false)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#define CRASH_WITH_INFO(...) do { \
bunPanicFromCrash(__FILE__, __LINE__, WTF_PRETTY_FUNCTION); \
} while (false)
`#define` CRASH_WITH_INFO(...) do { \
WTF::isIntegralOrPointerType(__VA_ARGS__); \
bunPanicFromCrash(__FILE__, __LINE__, WTF_PRETTY_FUNCTION); \
} while (false)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Source/WTF/wtf/Assertions.h` around lines 1019 - 1022, The BUN macro
CRASH_WITH_INFO currently discards __VA_ARGS__ and omits the type check, so
restore the compile-time guard by invoking
WTF::isIntegralOrPointerType(__VA_ARGS__) (or an equivalent
static_assert/type-trait expression) inside the macro while still not using the
values — for example evaluate the trait in a void-cast or unused constexpr to
force the type-check and then call bunPanicFromCrash(__FILE__, __LINE__,
WTF_PRETTY_FUNCTION); ensure the macro name CRASH_WITH_INFO and the
bunPanicFromCrash call remain unchanged and that only the type-check expression
referencing __VA_ARGS__ is added so non-integral/non-pointer arguments cause a
compile error.

@sosukesuzuki sosukesuzuki marked this pull request as draft February 24, 2026 05:46
- 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.
@github-actions
Copy link

Preview Builds

Commit Release Date
bb31db9e autobuild-preview-pr-167-bb31db9e 2026-02-24 06:25:33 UTC

@sosukesuzuki sosukesuzuki marked this pull request as ready for review February 24, 2026 07:54
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
Source/WTF/wtf/Assertions.h (1)

1019-1025: ⚠️ Potential issue | 🟡 Minor

Restore compile‑time type guard in BUN CRASH_WITH_INFO.
Line 1023 drops WTF::isIntegralOrPointerType(__VA_ARGS__), so non‑integral args compile in BUN builds but fail in non‑BUN. Re‑introduce the guard even if the values are ignored.

🛡️ Suggested fix
 `#define` CRASH_WITH_INFO(...) do { \
+        WTF::isIntegralOrPointerType(__VA_ARGS__); \
         bunPanicFromCrash(__FILE__, __LINE__, WTF_PRETTY_FUNCTION); \
     } while (false)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Source/WTF/wtf/Assertions.h` around lines 1019 - 1025, The CRASH_WITH_INFO
macro lost its compile-time guard allowing non-integral/non-pointer arguments in
BUN builds; restore a compile-time type check (using
WTF::isIntegralOrPointerType on __VA_ARGS__) inside CRASH_WITH_INFO so any
passed values are validated at compile time even though they are ignored, and
keep the existing call to bunPanicFromCrash(__FILE__, __LINE__,
WTF_PRETTY_FUNCTION); ensure the check is applied in the macro expansion (e.g.,
via a static_assert or a template helper referenced from CRASH_WITH_INFO) so
builds without BUN continue to enforce the same type constraints.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@Source/WTF/wtf/Assertions.h`:
- Around line 1019-1025: The CRASH_WITH_INFO macro lost its compile-time guard
allowing non-integral/non-pointer arguments in BUN builds; restore a
compile-time type check (using WTF::isIntegralOrPointerType on __VA_ARGS__)
inside CRASH_WITH_INFO so any passed values are validated at compile time even
though they are ignored, and keep the existing call to
bunPanicFromCrash(__FILE__, __LINE__, WTF_PRETTY_FUNCTION); ensure the check is
applied in the macro expansion (e.g., via a static_assert or a template helper
referenced from CRASH_WITH_INFO) so builds without BUN continue to enforce the
same type constraints.

ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 5f08a6c and bb31db9.

📒 Files selected for processing (2)
  • Source/WTF/wtf/Assertions.cpp
  • Source/WTF/wtf/Assertions.h

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant