oven-sh / bun

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

panic(main thread): incorrect alignment #11557

Open Atulin opened 2 months ago

Atulin commented 2 months ago

How can we reproduce the crash?

Crash occurred when reading, modifying, and writing 200+ json files in a loop. Each file's content was parsed with a Zod schema first, but the crash occurs even when the data is not parsed.

JavaScript/TypeScript code that reproduces the crash?

for (const { name, el } of elements) {
    const path = `./data/${name.replaceAll(/[\W\s]+/g, "-")}.json`;

    const file = Bun.file(path);
    const data: Item = await file.json();

    data.element_secondary = el;

    await Bun.write(path, JSON.stringify(data, null, 2));
}

Relevant log output

============================================================
Bun v1.1.12 (43f0913c) Windows x64
Args: "C:\Users\Angius\.bun\bin\bun.exe" ".\add-secondaries.mts"
Features: jsc transpiler_cache tsconfig_paths(2) tsconfig(4)
Builtins: "bun:main"
Elapsed: 7506ms | User: 93ms | Sys: 31ms
RSS: 0.14GB | Peak: 0.14GB | Commit: 0.21GB | Faults: 33864

panic(main thread): incorrect alignment
oh no: Bun has crashed. This indicates a bug in Bun, not your code.

Stack Trace (bun.report)

Bun v1.1.12 (43f0913) on windows x86_64 [AutoCommand]

panic: incorrect alignment

Jarred-Sumner commented 2 months ago

Any chance you could paste the JSON files?

Atulin commented 2 months ago

data.zip

Here it is, all the JSON files being used. The { name, el } come from the elements.txt file lines split by |, trimmed, and mapped to an object.

The files in the zip already have their element_secondary set, so you might want to remove those properties for a more true to life test.