-
Notifications
You must be signed in to change notification settings - Fork 401
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
feat: better failure messages when reading too much input #1950
Conversation
|
||
// Note: This cast could be truncating | ||
ctx.rt.state.input_stream.front().map(|data| data.len() as u32) | ||
// Note: This cast could be truncating on 64bit systems. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused by this comment. Is the call below safe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The length field of a vec is a usize, which is 32 or 64 bit depending on target.
You might have a vec with len here that is greater than 2^32 - 1, but it would fail in the vm (based on the checks done there) and if those werent there, it would fail while reading into uninit memory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
// 1. `ptr` was allocated using alloc | ||
// 2. Assume that the allocator in the VM doesn't deallocate in the input space. | ||
// 3. Size and length are correct from above. Length is <= capacity. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we keep this comment?
Co-authored-by: Ratan Kaliani <[email protected]>
Co-authored-by: Ratan Kaliani <[email protected]>
Previously, reading to much input would panic the executor and lead to ambiguous error messages,
this change means that u32::MAX len vecs will fail. It displays the callsite of
read
orread_vec