oven-sh / bun

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

Bun build crash when try to import wasm (on Mac) #13582

Open utensil opened 2 weeks ago

utensil commented 2 weeks ago

What version of Bun is running?

1.1.25+fe62a6140

What platform is your computer?

Darwin 23.4.0 arm64 arm

What steps can reproduce the bug?

bun install @myriaddreamin/typst.ts @myriaddreamin/typst-ts-web-compiler @myriaddreamin/typst-ts-renderer

bun build typst.ts -outdir output

where typst.ts is

import { $typst } from '@myriaddreamin/typst.ts/dist/esm/contrib/snippet.mjs';
// The following paths come from https://github.com/Myriad-Dreamin/typst.ts/blob/main/packages/typst.ts/examples/all-in-one-lite.html
import typst_ts_web_compiler_bg from '@myriaddreamin/typst-ts-web-compiler/pkg/typst_ts_web_compiler_bg.wasm';
import typst_ts_renderer_bg from '@myriaddreamin/typst-ts-renderer/pkg/typst_ts_renderer_bg.wasm';

$typst.setCompilerInitOptions({
    getModule: () => typst_ts_web_compiler_bg,
});
$typst.setRendererInitOptions({
    getModule: () => typst_ts_renderer_bg,
});

What is the expected behavior?

The WASMs loaded as strings to pass to $typst.set*Options functions.

What do you see instead?

Bun v1.1.25 (fe62a61) on macos aarch64 [BuildCommand]

Segmentation fault at address 0x00000004

Additional information

Similar to #13183 .

utensil commented 2 weeks ago

@paperdave Hi, thanks for the triage, do you have any clue why this is happening? Thanks!

Locally, I've bypassed this by manually copying the wasm files and set the urls myself. But I'm looking forward to a fix in the long run.

utensil commented 5 days ago

The same issue is still there in 1.1.27:

Bun v1.1.27 ([`267afa2`](<https://github.com/oven-sh/bun/tree/267afa293483d5ed5f834a6d35350232188e3f98>)) on macos aarch64 [RunCommand]

Segmentation fault at address 0x00000004

- *2 unknown/js code*
- `src.bundler.bundle_v2.LinkerContext.generateChunksInParallel`
- `Thread.PosixThreadImpl.spawn__anon_171961.Instance.entryFn`

<!-- from bun.report: KetL-BpxUb76FE7rDeKl -->