Skip to content

Bun v1.0.15 crashes building a small AWS CDK stack #7459

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

Closed
asilvas opened this issue Dec 4, 2023 · 9 comments
Closed

Bun v1.0.15 crashes building a small AWS CDK stack #7459

asilvas opened this issue Dec 4, 2023 · 9 comments
Labels
bug Something isn't working bundler Something to do with the bundler crash An issue that could cause a crash regression

Comments

@asilvas
Copy link
Contributor

asilvas commented Dec 4, 2023

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

@asilvas asilvas added the bug Something isn't working label Dec 4, 2023
@Electroid Electroid added crash An issue that could cause a crash bundler Something to do with the bundler labels Dec 4, 2023
@jrcichra
Copy link

jrcichra commented Dec 4, 2023

Seeing similar behavior with cdk8s.

@paperclover
Copy link
Contributor

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

@paperclover
Copy link
Contributor

wait this reads like the prettier crash fixed by increasing the stack size #7476. can you try the latest canary build?

@paperclover paperclover self-assigned this Dec 6, 2023
@paperclover
Copy link
Contributor

paperclover commented Dec 6, 2023

@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
image

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:

image

lol

@krk
Copy link
Contributor

krk commented Dec 12, 2023

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

@asilvas
Copy link
Contributor Author

asilvas commented Jan 3, 2024

Possibly related to #7428 and #7820

@paperclover paperclover removed their assignment Jan 8, 2024
@paperclover
Copy link
Contributor

smaller repro:

wow, i get illegal instruction on this one.

image

@Jarred-Sumner
Copy link
Collaborator

Duplicate of #5398

@Jarred-Sumner Jarred-Sumner marked this as a duplicate of #5398 May 13, 2024
@Jarred-Sumner
Copy link
Collaborator

This is a JavaScript transpiler stack overflow.

We will fix it, but to reduce the number of duplicated issues please follow along in #5398

@Jarred-Sumner Jarred-Sumner closed this as not planned Won't fix, can't repro, duplicate, stale May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working bundler Something to do with the bundler crash An issue that could cause a crash regression
Projects
None yet
Development

No branches or pull requests

6 participants