Skip to content
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

SegmentationFault at 26 when parsing json #826

Closed
romanetsdev opened this issue Jul 22, 2022 · 6 comments
Closed

SegmentationFault at 26 when parsing json #826

romanetsdev opened this issue Jul 22, 2022 · 6 comments
Labels
bug Something isn't working crash An issue that could cause a crash

Comments

@romanetsdev
Copy link

Version

0.1.4

Platform

21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:37 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T6000 arm64

What steps will reproduce the bug?

super simple code to reproduce here:
https://github.com/romanetsdev/bun-json-bug

run with: bun run index.js

How often does it reproduce? Is there a required condition?

reproduces with unexpected frequency

What is the expected behavior?

log with parsed json object on every run

What do you see instead?

SegmentationFault at 26

–––– bun meta ––––
Bun v0.1.4 macOS Silicon 21.5.0
RunCommand:
Elapsed: 8ms | User: 9ms | Sys: 6ms
RSS: 19.15MB | Peak: 19.15MB | Commit: 69.22MB | Faults: 0
–––– bun meta ––––

Additional information

bun-json-bug.mov
@romanetsdev romanetsdev added bug Something isn't working needs repro Needs an example to reproduce labels Jul 22, 2022
@Jarred-Sumner
Copy link
Collaborator

Most likely this is a bug in .json() memory management

@sewe75
Copy link

sewe75 commented Jul 23, 2022

Works fine when awaiting:

const data = await Bun.file('data.json').json();
console.log(data);

Maybe when chaining it does not wait for the promise to be resolved?

@SelfMadeSystem
Copy link

SelfMadeSystem commented Sep 11, 2022

I think it's fixed in the latest bun version.

I just tested it now with bun v0.1.11 and it didn't segfault. I'm on Arch Linux 5.19.7-zen2-1-zen #1 ZEN SMP PREEMPT_DYNAMIC Mon, 05 Sep 2022 18:33:28 +0000 x86_64 GNU/Linux

Edit: Just tested it again. It segfaulted after 20 successful attempts and again after 45 successful attempts.

@kt3k
Copy link

kt3k commented Sep 14, 2022

I still see the segfault with Bun.file("data.json").json().then(console.log); in bun 0.1.11. The possibility is very small (like ~10%) though

(my env is Darwin Kernel Version 19.6.0: Thu May 6 00:48:39 PDT 2021; root:xnu-6153.141.33~1/RELEASE_X86_64 x86_64)

@github-actions github-actions bot removed the crash label Oct 22, 2022
@Electroid
Copy link
Contributor

This is still an issue as of 0.2.2, we will get this fixed.

{"data":1}
Bun.file("data.json").json().then(console.log);

Then run bun run twice.

@Electroid Electroid added crash An issue that could cause a crash and removed needs repro Needs an example to reproduce labels Nov 3, 2022
@Jarred-Sumner
Copy link
Collaborator

image

fixed as of bun v0.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working crash An issue that could cause a crash
Projects
None yet
Development

No branches or pull requests

7 participants