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

feat: better failure messages when reading too much input #1950

Merged
merged 8 commits into from
Jan 17, 2025
Merged

Conversation

nhtyy
Copy link
Collaborator

@nhtyy nhtyy commented Jan 17, 2025

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 or read_vec


// 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.
Copy link
Member

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?

Copy link
Collaborator Author

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.

Copy link
Member

@ratankaliani ratankaliani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines -43 to -45
// 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.
Copy link
Member

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?

crates/core/executor/src/syscalls/hint.rs Outdated Show resolved Hide resolved
crates/zkvm/entrypoint/src/lib.rs Outdated Show resolved Hide resolved
@nhtyy nhtyy merged commit df100c9 into dev Jan 17, 2025
12 checks passed
@nhtyy nhtyy deleted the n/track_caller branch January 17, 2025 20:48
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 this pull request may close these issues.

2 participants