oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.27k stars 2.77k forks source link

Crash when using `bun test [query]` and most of the time `bun run` #9982

Closed n0thhhing closed 6 months ago

n0thhhing commented 7 months ago

What version of Bun is running?

Tested on bun 1.1.1, 1.0, and 1.0.32

What platform is your computer?

What is the expected behavior?

bun test disasm iter
bun test v1.0.32 (5fec71bd)

src/tests/disasm.test.ts:
✓ disasm ARM64 [116.60ms]

src/tests/iter.test.ts:
✓ disasm_iter ARM [44.74ms]
✓ disasm_iter ARM64 [10.77ms]

What do you see instead?

On Arch Linux and Debian, this issue occurs frequently, while on Ubuntu, it consistently happens.


╰─ bun test disasm it
- bun test v1.0.32 (5fec71bd)

src/tests/disasm.test.ts:
fish: Job 1, 'bun test disasm it' terminated by signal SIGSEGV (Address boundary error)

For bun run:

bun run src/tests/disasm.test.ts
fish: Job 1, 'bun run src/tests/disasm.test.ts' terminated by signal SIGSEGV (Address boundary error)

What steps can reproduce the bug?

No additional build steps are required to run the code, as all necessary files have already been generated using Emscripten. You can find the code to reproduce the issue on the SIGSEGV branch of the capstone-wrapper repository.

- Running `bun test disasm iter` results in immediate termination (SIGSEGV) without executing any code.
- Alternatively, `bun run src/tests/disasm*` should technically be
  executable but behaves similarly to 'bun test' by throwing a SIGSEGV
  error. This indicates that the issue may not be with the code itself,
  but rather with the parsing or transpiling process. Notably,
  even adding `console.log` statements at the top level does not
  produce any output in either case.

The primary source files, where most functions originate from, are src/wrapper.ts and src/memory.ts. While memory.ts doesn't technically execute any code, wrapper.ts serves as the entry point, initializing the Emscripten instance and importing a significant portion of the codebase. It's noteworthy that neither of these files throws any errors when executed.

Additional information

n0thhhing commented 7 months ago

This happends via bun run too also, it doesn't even throw the "Cannot use test() outside of the test runner. Run "bun test" to run tests" Error, it instantly throws segmentation fault(in most cases, sometimes it does work), also this will throw if the code is importing the wrapper.ts file

KyrylR commented 7 months ago

Have the same issue with bun test in CI: https://github.com/dl-solarity/zktype/actions/runs/8723755844/job/23932703629

Occurs not consistently but from time to time

Jarred-Sumner commented 6 months ago

Duplicate of #5398

Jarred-Sumner commented 6 months ago

This is a JavaScript transpiler stack overflow.

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