bun
bun copied to clipboard
Bun v1.0.15 crashes building a small AWS CDK stack
What version of Bun is running?
1.0.15+b3bdf22eb (was also able to repro with a 16 canary)
What platform is your computer?
Linux 6.2.0-37-generic x86_64 x86_64
What steps can reproduce the bug?
// test.ts
import { Stack } from 'aws-cdk-lib';
export class TestStack extends Stack {
constructor(scope, id) {
super(scope, id);
}
}
bun build ./test.ts
What is the expected behavior?
Builds, no crash. Worked fine in v1.0.14 and earlier.
What do you see instead?
Segmentation fault (core dumped)
I've tried gdb and valgrind as well to try and get more details, but didn't notice anything useful.
valgrind -v bun build ./test.ts
==66428== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==66428== Access not within mapped region at address 0xC15C068
==66428== at 0x346BFD5: ??? (in /home/user/.bun/bin/bun)
==66428== If you believe this happened as a result of a stack
==66428== overflow in your program's main thread (unlikely but
==66428== possible), you can try to increase the size of the
==66428== main thread stack using the --main-stacksize= flag.
==66428== The main thread stack size used in this run was 18446744073709551615.
And using the core dump gdb doesn't show anything useful:
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00005569b34dfd0b in ?? ()
[Current thread is 1 (Thread 0x7f19635fd6c0 (LWP 66642))]
(gdb) bt
#0 0x00005569b34dfd0b in ?? ()
#1 0x00005569b34e0009 in ?? ()
#2 0x00005569b34e0009 in ?? ()
and last few lines:
#507 0x00005569b323857c in ?? ()
#508 0x00005569b303e2d5 in ?? ()
#509 0x00005569b3039e98 in ?? ()
#510 0x00005569b3123ccb in ?? ()
#511 0x00005569b2ab3efb in ?? ()
#512 0x00005569b2e9df26 in ?? ()
#513 0x00007f1963a8f6ba in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:444
#514 0x00007f1963b1e0d0 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
Additional information
I've tried numerous workarounds to try and narrow it further, but no luck. Simply extending CDK Stack class is all it takes. I've tried older CDK versions, resetting tsconfig.json, reinstalling packages (via bun and npm).
Seeing similar behavior with cdk8s.
note: to get more useful information of a core dump, download bun-profile from the github releases, and you can then debug a core from bun (non profile) with lldb ./bun-profile -c coredump
wait this reads like the prettier crash fixed by increasing the stack size #7476. can you try the latest canary build?
@dylan-conway Stack overflow in a different function. Not a recursion bug but because the file given is literally 70kb and the recursion (probably comma operators) is that deep.
bun i aws-cdk-lib
bun build ./node_modules/aws-cdk-lib/index.js
This file cant even be formatted by prettier because it ALSO stack overflows.
I wonder if we can get away with just increasing the stack size, just to solve this regression. But we really need to solve this issue for real. Related bundler test which is currently disabled "NestedLabelsBundle"
That fixture is as follows:
lol
Tested with 1.17.0, segfault happens while parsing node_modules/aws-cdk-lib/region-info/lib/built-ins.generated.js, because of deep recursion via https://github.com/oven-sh/bun/blob/7ec64c2cc82e8bdd1a87f5696b587c27422a6a6f/src/js_parser.zig#L1743
smaller repro:
npm i aws-cdk-lib
bun node_modules/aws-cdk-lib/region-info/lib/built-ins.generated.js
Possibly related to https://github.com/oven-sh/bun/issues/7428 and https://github.com/oven-sh/bun/issues/7820
smaller repro:
wow, i get illegal instruction on this one.
Is there any updates on this?, the issue still seems to persist.
Duplicate of https://github.com/oven-sh/bun/issues/5398
This is a JavaScript transpiler stack overflow.
We will fix it, but to reduce the number of duplicated issues please follow along in #5398