-
Notifications
You must be signed in to change notification settings - Fork 138
[hermes] Don't pass overly-long arguments to Charon #3044
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
Open
joshlf
wants to merge
1
commit into
Gtu5rhuk5rjkrhhqpfwbmniejgf57ogzn
Choose a base branch
from
Gulbf5jp7zpz4nn77nspxpsiy3tadde54
base: Gtu5rhuk5rjkrhhqpfwbmniejgf57ogzn
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,7 +38,23 @@ pub fn run_charon(args: &Args, roots: &Roots, packages: &[HermesArtifact]) -> Re | |
| // deterministic ordering for testing (not important in production). | ||
| let mut start_from = artifact.start_from.clone(); | ||
| start_from.sort(); | ||
| cmd.arg("--start-from").arg(start_from.join(",")); | ||
|
|
||
| let start_from_str = start_from.join(","); | ||
| // OS command-line length limits (Windows is ~32k; Linux `ARG_MAX` is | ||
| // usually larger, but variable) | ||
| const ARG_CHAR_LIMIT: usize = 32_768; | ||
| if start_from_str.len() > ARG_CHAR_LIMIT { | ||
| // FIXME: Pass the list of entry points to Charon via a file instead | ||
| // of the command line. | ||
| bail!( | ||
| "The list of Hermes entry points for package '{}' is too large ({} bytes). \n\ | ||
| This exceeds safe OS command-line limits.", | ||
|
Comment on lines
+50
to
+51
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The indentation on this line will be included in the final error message string, which is likely not intended and will result in a large amount of whitespace at the beginning of the second line of the error message. Consider removing the leading spaces for cleaner output. "The list of Hermes entry points for package '{}' is too large ({} bytes). \nThis exceeds safe OS command-line limits.", |
||
| artifact.name.package_name, | ||
| start_from_str.len() | ||
| ); | ||
| } | ||
|
|
||
| cmd.arg("--start-from").arg(start_from_str); | ||
|
|
||
| // Separator for the underlying cargo command | ||
| cmd.arg("--"); | ||
|
|
||
1 change: 1 addition & 0 deletions
1
tools/hermes/tests/fixtures/os_arg_limit_exceeded/expected_status.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| failure |
1 change: 1 addition & 0 deletions
1
tools/hermes/tests/fixtures/os_arg_limit_exceeded/expected_stderr.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| The list of Hermes entry points for package 'large_pkg' is too large |
Empty file.
6 changes: 6 additions & 0 deletions
6
tools/hermes/tests/fixtures/os_arg_limit_exceeded/source/Cargo.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| [package] | ||
| name = "large_pkg" | ||
| version = "0.1.0" | ||
| edition = "2021" | ||
|
|
||
| [dependencies] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
For better code organization and to signal that this constant is not dependent on the loop, consider defining
ARG_CHAR_LIMITand its explanatory comment outside theforloop, for example, at the function level. Whileconstmeans no runtime cost, this improves readability and maintainability.