Segmentation fault in Bun Shell
How can we reproduce the crash?
No response
Relevant log output
Bun v1.1.20 (ae194892) macOS Silicon
macOS v13.3
Features: jsc Bun.stderr(12) Bun.stdout(12) shell(40) spawn(15)
Builtins: "bun:main"
Elapsed: 33446ms | User: 28ms | Sys: 154ms
RSS: 11.89MB | Peak: 25.15MB | Commit: 1.07GB | Faults: 2868
panic(main thread): Segmentation fault at address 0x8
oh no: Bun has crashed. This indicates a bug in Bun, not your code.
Stack Trace (bun.report)
Bun v1.1.20 (ae19489) on macos aarch64 [AutoCommand]
Segmentation fault at address 0x00000008
- 2 unknown/js code
-
src.shell.interpreter.StatePtrUnion -
src.shell.interpreter.Interpreter.Expansion.next -
src.shell.interpreter.StatePtrUnion -
src.shell.interpreter.Interpreter.Expansion.next -
src.shell.interpreter.StatePtrUnion -
src.shell.interpreter.Interpreter.Expansion.next -
src.shell.interpreter.StatePtrUnion -
src.shell.interpreter.Interpreter.Script.start
@7flash, the latest version of Bun is v1.1.26, but this crash was reported on Bun v1.1.20.
Are you able to reproduce this crash on the latest version of Bun?
bun upgrade
@7flash can you paste the last shell script that was run?
@7flash can you paste the last shell script that was run?
I have this program running continuously for days and it looks something like this:
first.sh
while IFS= read -r it; do #iterate over things
bun second.ts "${it}" > answer.txt
vim answer.txt
done < "$things"
second.ts
const it = await Bun.password.hash(process.argv[2])
const answer = await $`python3 third.py "${it}"`
console.log(answer)
third.py
it = sys.argv[1]
answer = generate(it)
print(answer)
Its just a minimal reproduction to demonstrate the flow of my program, which you might find unconventional so let me explain:
In my terminal I am running first.sh which runs second.ts which runs third.py
The reason I am running first.sh because its the only way I can completely pause my program while I am reviewing answer.txt and fixing second/third scripts, in the same terminal window, its really special experience for me being to be able to do it in my favourite editor vim/helix instead of opening some web ui. I hope its not too crazy, but please let me know if there are any drawbacks i must be aware when building apps following this approach.
Anyway, the moment something went wrong, is most probably when I tried to airdrop some large files into my macbook where the script was running, and that might have caused the memory issue, when I noticed the script has stopped running, while being at stage of waiting response from third.py.
I am curious about what can I understand from this error message, specifically what following number mean?
shell(40) User: 28ms Commit: 1.07GB | Faults: 2868
Btw I've found something in docs which gives me hope it might be possible to switch from running script to editing file in a terminal? But it doesn't work, it's not doing anything when I run this script.
Bun.openInEditor(import.meta.url, { editor: "hx", });
I was also getting segfault 0x8 .
To anybody else experiencing this I was able to get around it by switching my Bun.$ calls with Bun.Spawn
We've fixed a lot of reliability issues in the shell since the time this was reported. Please let us know if you continue to run into this.