You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
assertion failed: bpos.to_u32() >= mbc.pos.to_u32() + mbc.bytes as u32 #92267
searched nightlies: from nightly-2021-01-01 to nightly-2021-12-24
regressed nightly: nightly-2021-10-02
searched commits: from aa7aca3 to c02371c
regressed commit: b6057bf
I've been taking a look at this. It's pretty interesting. I'm not entirely sure I'll be able to work it out, but I figure I may as well assign myself for the time being while I attempt to solve it.
The problem seems to reside within the crate rustc_builtin_macros, in the files format.rs and format_foreign.rs. The function expand_preparsed_format_args in format.rs has a macro, check_foreign!, which is in charge of looking for foreign substitutions - that is, someone using printf or shell style formatting rather than Rust's style. It's a macro so it can be generic over the two types of substitution.
The first time this macro is called, for printf substitutions, it finds two (I think "%%" and "%", though I'm not sure it's exactly that). The code that actually detects the substitutions is in format_foreign.rs. When parsing the substitution, in the function printf::parse_next_substitution, it is somehow finding that the second substitution has a boundary in the middle of the 🦀 character. I'm not sure exactly how yet. This gets turned into a span in expand_preparsed_format_args. The span is malformed, as it splits a character in two, so the second the code tries to use it for anything it trips an assertion and causes this ICE.
The remaining problem is figuring out what's going wrong in printf::parse_next_substitution. This sort of string manipulation is not my forte. I'll probably take another few cracks at it though.
@inquisitivecrystal yes, I get the exact same error. Playground. The error disappears if you add a new line after the á, so maybe your text editor did that automatically.
@inquisitivecrystal yes, I get the exact same error. Playground. The error disappears if you add a new line after the á, so maybe your text editor did that automatically.
That was it, thanks.
I'm going to unassign myself from this. I do hope my exploration ends up being helpful to whoever fixes it though. @dwrensha: if you want to fix this yourself, you certainly seem further along than I was, though you shouldn't feel any pressure to do so if you don't want to.
Activity
dwrensha commentedon Dec 25, 2021
searched nightlies: from nightly-2021-01-01 to nightly-2021-12-24
regressed nightly: nightly-2021-10-02
searched commits: from aa7aca3 to c02371c
regressed commit: b6057bf
bisected with cargo-bisect-rustc v0.6.0
Host triple: x86_64-unknown-linux-gnu
Reproduce with:
dwrensha commentedon Dec 25, 2021
The regression happened in #89340. cc @FabianWolff.
BGR360 commentedon Dec 25, 2021
@rustbot label regression-from-stable-to-stable
apiraino commentedon Dec 28, 2021
Assigning priority as discussed in the Zulip thread of the Prioritization Working Group.
@rustbot label -I-prioritize +P-low
inquisitivecrystal commentedon Dec 28, 2021
I've been taking a look at this. It's pretty interesting. I'm not entirely sure I'll be able to work it out, but I figure I may as well assign myself for the time being while I attempt to solve it.
Badel2 commentedon Dec 29, 2021
Another test case:
inquisitivecrystal commentedon Dec 30, 2021
I'm somewhat confused. Are you getting the same error from this? I'm having trouble reproducing.
inquisitivecrystal commentedon Dec 30, 2021
The problem seems to reside within the crate
rustc_builtin_macros, in the filesformat.rsandformat_foreign.rs. The functionexpand_preparsed_format_argsinformat.rshas a macro,check_foreign!, which is in charge of looking for foreign substitutions - that is, someone using printf or shell style formatting rather than Rust's style. It's a macro so it can be generic over the two types of substitution.The first time this macro is called, for printf substitutions, it finds two (I think "%%" and "%", though I'm not sure it's exactly that). The code that actually detects the substitutions is in
format_foreign.rs. When parsing the substitution, in the functionprintf::parse_next_substitution, it is somehow finding that the second substitution has a boundary in the middle of the🦀character. I'm not sure exactly how yet. This gets turned into a span inexpand_preparsed_format_args. The span is malformed, as it splits a character in two, so the second the code tries to use it for anything it trips an assertion and causes this ICE.The remaining problem is figuring out what's going wrong in
printf::parse_next_substitution. This sort of string manipulation is not my forte. I'll probably take another few cracks at it though.dwrensha commentedon Dec 30, 2021
Something is broken about
printf::Substitutions::pos.This change makes the ICE go away (but probably breaks other things):
dwrensha commentedon Dec 30, 2021
When
parse_next_substitution()returns here:rust/compiler/rustc_builtin_macros/src/format_foreign.rs
Line 343 in d331cb7
it seems like we should increment
self.posbystart + 2, but we actually only increment it by 2:rust/compiler/rustc_builtin_macros/src/format_foreign.rs
Line 314 in d331cb7
Badel2 commentedon Dec 30, 2021
@inquisitivecrystal yes, I get the exact same error. Playground. The error disappears if you add a new line after the
á, so maybe your text editor did that automatically.inquisitivecrystal commentedon Dec 31, 2021
That was it, thanks.
I'm going to unassign myself from this. I do hope my exploration ends up being helpful to whoever fixes it though. @dwrensha: if you want to fix this yourself, you certainly seem further along than I was, though you shouldn't feel any pressure to do so if you don't want to.
dwrensha commentedon Dec 31, 2021
I put up a PR for a fix: #92460
dwrensha commentedon Dec 31, 2021
@Badel2 I opened a new issue for your bug, because it's not exactly the same as this one.
#92462
Rollup merge of rust-lang#92460 - dwrensha:fix-92267, r=petrochenkov