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

packages with names over 1024 crash the resolver #9020

Open
paperdave opened this issue Feb 21, 2024 · 4 comments
Open

packages with names over 1024 crash the resolver #9020

paperdave opened this issue Feb 21, 2024 · 4 comments
Labels
bug Something isn't working crash An issue that could cause a crash good first issue Something that would be good for new contributors

Comments

@paperdave
Copy link
Collaborator

What version of Bun is running?

No response

What platform is your computer?

No response

What steps can reproduce the bug?

bun run boo

package.json

What is the expected behavior?

to not crash

What do you see instead?

thread 2355986 panic: reached unreachable code
/Users/dave/code/bun/.cache/zig/lib/std/debug.zig:342:14: 0x100329abf in assert (bun-zig)
    if (!ok) unreachable; // assertion failure
             ^
/Users/dave/code/bun/src/bun.zig:364:60: 0x1003844a3 in copy__anon_46322 (bun-zig)
    if (comptime Environment.allow_assert) std.debug.assert(dest.len >= src.len);
                                                           ^
/Users/dave/code/bun/src/resolver/package_json.zig:64:17: 0x100be4faf in generateHash (bun-zig)
        bun.copy(u8, &hashy, package_json.name);
                ^
/Users/dave/code/bun/src/resolver/package_json.zig:1022:42: 0x1007727af in parse__anon_87999 (bun-zig)
                package_json.generateHash();
image

Additional information

issue found by @ryanccn, thanks for this reproduction

@paperdave paperdave added bug Something isn't working crash An issue that could cause a crash good first issue Something that would be good for new contributors labels Feb 21, 2024
@RandoomWalks
Copy link

@paperdave
2 thoughts:
allocate a buffer dynamically based on the length of the package name.
or
iteratively hash smaller chunks

@paperdave
Copy link
Collaborator Author

this should hash smaller chunks if it cannot entirely fit into 1024 bytes.

@sequencerr
Copy link
Contributor

@paperdave I'm sorry if the problem is not about matching other's standards, but
https://docs.npmjs.com/cli/v10/configuring-npm/package-json#name

The name must be less than or equal to 214 characters.

@sequencerr
Copy link
Contributor

Maybe display message about invalid name?

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 good first issue Something that would be good for new contributors
Projects
None yet
Development

No branches or pull requests

3 participants