-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compiler segfault in InternPool.indexToKey
during sema likely due to invalid index
#22824
Comments
Incomplete reproduction; I don't know what your diff is against, nor what command to run to reproduce the crash. Please either say what to apply the diff against, or ideally just provide a branch which reproduces the bug; and say what command to run to trigger the crash. |
Sorry - here is a commit you can checkout To repro: First run: # Necessary to run the codegen step before zig build runs
bun run build Once it starts compiling a bunch of C++ you can CTRL + C Then run zig build check And that should fail pretty quickly with a message like this: obj
└─ zig build-obj bun-debug Debug aarch64-macos.13.0-none failure
error: the following command terminated unexpectedly:
/Users/jarred/Code/bun/vendor/zig/zig build-obj -freference-trace=24 -fllvm -fno-lld -fno-strip -fno-omit-frame-pointer -fPIC -ODebug -target aarch64-macos.13.0-none -mcpu apple_m1 --dep async_io --dep zlib-internal --dep async --dep ZigGeneratedClasses --dep ResolvedSourceTag --dep ErrorCode --dep build_options --dep translated-c-headers -Mroot=/Users/jarred/Code/bun/root.zig -Masync_io=/Users/jarred/Code/bun/src/io/io_darwin.zig -Mzlib-internal=/Users/jarred/Code/bun/src/deps/zlib.posix.zig -Masync=/Users/jarred/Code/bun/src/async/posix_event_loop.zig -MZigGeneratedClasses=/Users/jarred/Code/bun/build/debug/codegen/ZigGeneratedClasses.zig -MResolvedSourceTag=/Users/jarred/Code/bun/build/debug/codegen/ResolvedSourceTag.zig -MErrorCode=/Users/jarred/Code/bun/build/debug/codegen/ErrorCode.zig -Mbuild_options=/Users/jarred/Code/bun/build/debug/cache/zig/local/c/71043ec0281e8832a9875d3532e32536/options.zig -ODebug -target aarch64-macos.13.0-none -mcpu apple_m1 -Mtranslated-c-headers=/Users/jarred/Code/bun/build/debug/cache/zig/local/o/21185a03a8290413fcee447f7caa5e1f/c-headers-for-zig.zig -lc++ -lc --cache-dir /Users/jarred/Code/bun/build/debug/cache/zig/local --global-cache-dir /Users/jarred/Code/bun/build/debug/cache/zig/global --name bun-debug -fno-compiler-rt --zig-lib-dir /Users/jarred/Code/bun/vendor/zig/lib/ --listen=-
Build Summary: 2/5 steps succeeded; 1 failed
obj transitive failure
├─ zig build-obj bun-debug Debug aarch64-macos.13.0-none failure
└─ install generated to bun-zig.o transitive failure
└─ zig build-obj bun-debug Debug aarch64-macos.13.0-none (+2 more reused dependencies)
error: the following build command failed with exit code 1:
/Users/jarred/Code/bun/build/debug/cache/zig/local/o/164273aabf6bf1b3f1bc532a6ee1b6f6/build /Users/jarred/Code/bun/vendor/zig/zig /Users/jarred/Code/bun/vendor/zig/lib /Users/jarred/Code/bun /Users/jarred/Code/bun/build/debug/cache/zig/local /Users/jarred/Code/bun/build/debug/cache/zig/global --seed 0xb72d8224 -Z5e6e00b40476db49 obj --prefix /Users/jarred/Code/bun/build/debug -Dobj_format=obj -Dtarget=aarch64-macos-none -Doptimize=Debug -Dcpu=apple_m1 -Denable_logs=true -Dversion=1.2.3 -Dreported_nodejs_version=22.6.0 -Dcanary=1 -Dcodegen_path=/Users/jarred/Code/bun/build/debug/codegen -Dcodegen_embed=false --prominent-compile-errors -Dsha=2644bad5d472e4306232bc7cafa61d93b978e90a
FAILED: bun-zig.o /Users/jarred/Code/bun/build/debug/bun-zig.o
cd /Users/jarred/Code/bun && /Users/jarred/Code/bun/vendor/zig/zig build obj --cache-dir /Users/jarred/Code/bun/build/debug/cache/zig/local --global-cache-dir /Users/jarred/Code/bun/build/debug/cache/zig/global --zig-lib-dir /Users/jarred/Code/bun/vendor/zig/lib --prefix /Users/jarred/Code/bun/build/debug -Dobj_format=obj -Dtarget=aarch64-macos-none -Doptimize=Debug -Dcpu=apple_m1 -Denable_logs=true -Dversion=1.2.3 -Dreported_nodejs_version=22.6.0 -Dcanary=1 -Dcodegen_path=/Users/jarred/Code/bun/build/debug/codegen -Dcodegen_embed=false --prominent-compile-errors -Dsha=2644bad5d472e4306232bc7cafa61d93b978e90a
ninja: build stopped: subcommand failed.
cmake took 0.34 seconds My hunch is it's something to do with non power of 2 sized integers and packed structs At one point the following diff caused it to stop crashing briefly, but I didn't commit the code to get everything else that changed - const cp_len = wtf8ByteSequenceLength(it.bytes[pos]);
+ const cp_len: u3 = @intCast(wtf8ByteSequenceLength(it.bytes[pos])); |
It seems to happen for almost any compiler error on macOS arm64. Linux x64 correctly shows the error: info: zig compiler v0.14.0-dev.2987+183bb8b08
check
└─ zig build-obj bun-debug Debug native-native-gnu.2.27 1 errors
src/bundler/bundle_v2.zig:1786:31: error: struct 'src.jsc.API' has no member named 'Server'
page: *bun.JSC.API.Server.PageBundleRoute,
~~~~~~~~~~~^~~~~~~
src/jsc.zig:30:17: note: struct declared here
pub const API = struct {
^~~~~~
referenced by: |
Okay I have a better reproduction. It stops crashing when commenting out the two line diff in oven-sh/bun@6630f3b |
Zig Version
0.14.0-dev.2987+183bb8b08
Steps to Reproduce and Observed Behavior
Seeing a crash during semantic analysis in Bun when there is likely a compiler error or two.
It's probably an invalid
index
being passed.This was the diff in Bun that led to the crash:
Expected Behavior
Error(s) showing where my code is wrong
The text was updated successfully, but these errors were encountered: