Files
bun.sh/src
Claude Bot 84545edc9f Fix crash when visiting properties in macro-generated objects
Fixes #24505

## Problem

Bun was crashing with segmentation faults when building projects that use
macros returning large objects. The crash was flaky and occurred during the
AST visiting phase when processing object properties.

The issue was in `visitExpr.zig` where property values, keys, and
initializers were being accessed using the unsafe `property.value.?` pattern
after checking `property.value != null`. While this appears safe, in
certain edge cases (particularly with macro-generated objects), the check
and use were not atomic, leading to potential null pointer dereferences.

## Solution

Replace the unsafe optional access patterns with Zig's safe optional
unwrapping syntax:

- Before: `if (property.value != null) { use(property.value.?); }`
- After: `if (property.value) |val| { use(val); }`

This ensures that the value is captured and used atomically, preventing
race conditions or other issues that could cause crashes.

Changes made in three locations:
1. e_jsx_element property visiting (lines 210-222)
2. e_object property visiting (lines 1088-1105)

## Test Plan

Added regression test `test/regression/issue/24505.test.ts` that:
- Creates a macro that generates an object with 50 properties
- Runs the build 3 times to catch flaky crashes
- Verifies no segmentation faults or panics occur

Tested with the original reproduction case from the issue - the visiting
phase no longer crashes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-08 10:26:34 +00:00
..
2025-10-16 21:52:22 -04:00
2025-07-21 13:26:47 -07:00
2025-10-04 02:17:55 -07:00
2025-07-29 19:35:46 -07:00
2025-07-21 13:26:47 -07:00
2025-07-21 13:26:47 -07:00
2025-09-09 20:41:10 -07:00
2025-10-23 17:52:13 -07:00
2025-09-11 23:29:53 -07:00
2025-10-25 00:05:28 -07:00
2025-09-09 20:41:10 -07:00
2025-07-21 13:26:47 -07:00
2025-07-21 13:26:47 -07:00
2025-07-21 13:26:47 -07:00