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

May panic due to unwrap on Err #200

Closed
Koral77 opened this issue Apr 5, 2023 · 2 comments · Fixed by #205
Closed

May panic due to unwrap on Err #200

Koral77 opened this issue Apr 5, 2023 · 2 comments · Fixed by #205

Comments

@Koral77
Copy link

Koral77 commented Apr 5, 2023

I've using afl.rs to fuzz this crate. And I found a panic issue. The code to replay the issue is

let mut _local0 = bumpalo::Bump::with_capacity(10995706271387654244);

And from the panic reportn, it seems that this panic is caused by use unwrap on a Result which may return err.
image
I hope you can check if this is a bug need to be fixed. Thanks a lot.

@fitzgen
Copy link
Owner

fitzgen commented Apr 10, 2023

Thanks for filing an issue!

This particular behavior is expected, although we could maybe have a better panic message and need to add a section to the docs explaining that this can happen.

One can use try_with_capacity to handle OOM.

Can you share the fuzz target you've written? Could be good to get cargo fuzz fuzz targets committed in the repo, but I'm also just curious about the approach you've taken.

@Koral77
Copy link
Author

Koral77 commented Apr 11, 2023

@fitzgen Thanks for your reply!

I place the replay code on replay_files.

The file contains three lines of code, but the bug is triggered in the first line of code.

The reported bug is in lib.rs: 468 where the code is
image

It uses unwrap() on Err returned by Layout::from_size_align.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants