-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
rustc driver: Remove argument 0 before at-expansion to prevent ICE #109084
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @WaffleLapkin (or someone else) soon. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
The fix looks fine to me, may I ask however how did you find this/what is the use-case that is broken by this ICE? |
I found it by following the flow from the entry point, and it popped up to me as a potential issue. And it turned out right. |
Backtrace stuff from slightly outdated version, there no Some error handling there, shouldn't it work? rust/compiler/rustc_driver_impl/src/args.rs Lines 6 to 33 in cf8d98b
|
@klensy The bug is in |
Sorry, i still don't understand why this shouldn't be in |
@klensy |
pub fn arg_expand_all(at_args: &[String]) -> Vec<String> {
let mut args = Vec::new();
// don't care about argv[0]
for arg in at_args.iter().skip(1) {
...
}
} |
|
Lines 705 to 708 in cf8d98b
|
Now that I see this function is called in more places (only In any case, I'll wait to hear the team's opinion first. |
hello visiting this PR, checking progress. by reading this comment IIUC this is waiting on an input from the reviewer cc @WaffleLapkin ? thanks |
@apiraino I'm not sure how to answer the question, so maybe a reroll is appropriate here |
r? compiler Any input about #109084 (comment) ? |
Both adding the snippet before every use of |
So I can do either? (first option is already in place) |
Either
No, the snippet is not added to the use of |
Sorry, but the same day I posted my last comment, I lost Internet access for a quite long time, and since I focused on other things. I can take care of it now. |
This comment has been minimized.
This comment has been minimized.
@rustbot review |
r=me after squashing commits into one. |
3016cbe
to
6240d45
Compare
@rustbot review |
@bors r=petrochenkov |
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#108630 (Fix docs for `alloc::realloc`) - rust-lang#109084 (rustc driver: Remove argument 0 before at-expansion to prevent ICE) - rust-lang#111181 (fix(parse): return unpected when current token is EOF) - rust-lang#111656 (Use an unbounded lifetime in `String::leak`.) - rust-lang#111946 (rustdoc: Add `ItemTemplate` trait and related functions to avoid repetitively wrapping existing functions) - rust-lang#112018 (Clean up usage of `cx.tcx` when `tcx` is already set into a variable) r? `@ghost` `@rustbot` modify labels: rollup
Under Unix-based operating systems, when I execute rustc by setting argv0 to
@/dev/null
, it will expand command-line arguments from this file, leading to an empty arglist, which then triggers an ICE by trying to remove first argument.The panic message is this:
My fix is to remove the first argument before expanding arguments.
Full backtrace
I also checked if I can trigger a similar problem by passing empty argument list to
execve
, but at least under Linux, it seems to always insert an empty first argument if there are none.