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

Memory hog if Buffer.alloc(size, fill) is called with fill being a Buffer of length > size #9120

Closed
bc01ca opened this issue Feb 26, 2024 · 0 comments · Fixed by #9128
Closed
Labels
bug Something isn't working

Comments

@bc01ca
Copy link

bc01ca commented Feb 26, 2024

What version of Bun is running?

1.0.17+5e60861c3

What platform is your computer?

Darwin 23.3.0 arm64 arm

What steps can reproduce the bug?

bun repl

let abBuf = Buffer.alloc(2, "ab"); // abBuf set to Buffer(2) [Uint8Array] [ 97, 98 ]
let aBuf = Buffer.alloc(1, "ab"); // aBuf set to Buffer(1) [Uint8Array] [ 97 ]
let okBuf = Buffer.alloc(9, abBuf); // okBuf set to Buffer (9) [Uint8Array] [ 97, 98, 97, ..., 98, 97 ]
let x = Buffer.alloc(1, abBuf); // quit after a long idle

What is the expected behavior?

Buffer.alloc(1, abBuf) in the sample code above should produce the same result as Buffer.alloc(1, "ab"), ie, Buffer(1) [Uint8Array] [ 97 ]

What do you see instead?

"bun repl" quit after a mysterious long idle. Memory usage of bun shoot up to over 14G (ie, almost used up all my memory). Repeating this again, an alert pops up and Terminal application is enforced to quit.

Additional information

No response

@bc01ca bc01ca added the bug Something isn't working label Feb 26, 2024
Jarred-Sumner added a commit that referenced this issue Feb 27, 2024
Jarred-Sumner added a commit that referenced this issue Feb 27, 2024
* Fixes #9120

* Update buffer.test.js

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant