-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Fix env::ArgsOs
for zkVM
#139849
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
base: master
Are you sure you want to change the base?
Fix env::ArgsOs
for zkVM
#139849
Conversation
r? @ibraheemdev rustbot has assigned @ibraheemdev. Use |
This PR fixes the iterator, but leaves the arg retrieval and copying the same. There are some interesting alternatives to be considered there. rust/library/std/src/sys/args/zkvm.rs Lines 21 to 38 in 2da29db
It looks like the memory allocated by As for the comment about reimplementing |
The zkVM implementation of `env::ArgsOs` incorrectly reports the full length even after having iterated. Instead, use a range approach which works out to be simpler. Also, implement more iterator methods like the other platforms in rust-lang#139847.
Retrieve argc/argv from the host once, on demand when the first `env::ArgsOs` is constructed, and globally cache it. Copy each argument to an `OsString` while iterating.
I've now implemented the caching approach. The two commits are complete fixes with different approaches, so they should be considered separately until we decide. |
The zkVM implementation of
env::ArgsOs
incorrectly reports the full length even after having iterated. Instead, use a range approach which works out to be simpler. Also, implement more iterator methods like the other platforms in #139847.cc @flaub @jbruestle @SchmErik