-
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 index out of bounds libserialize\leb128.rs #37803
Comments
Do you have some more information on how to reproduce this? |
I hit this compiling hyper with 1.13 stable. |
Which version of hyper is that? I can't reproduce with latest |
It was with master. I tried |
Sounds a bit like cargo was re-using libraries that it should have re-compiled because the compiler has changed. cc @alexcrichton |
Sorry if I did not save the full backtrace - It was my first issue report. I switched away from 1.15 nightly back to 1.14 nightly in order to solve Cargo cleaning and rebuilding fixed the issue. I will make sure to run again and capture the output if it happens again. On 11/16/2016 4:54 PM, Michael Woerister wrote:
|
Sounds suspiciously like a Cargo bug! If there's a reproduction I'd be more than willing to dig in. |
I believe I just reproduced this in Cargo itself: $ cargo +nightly build
# ...
$ cargo +stable build -p cfg-if -v
Compiling cfg-if v0.1.0
Running `rustc /home/alex/.cargo/registry/src/github.com-1ecc6299db9ec823/cfg-if-0.1.0/src/lib.rs --crate-name cfg_if --crate-type lib -g -C metadata=72c1f992b13d5087 -C extra-filename=-72c1f992b13d5087 --out-dir /home/alex/code/cargo/wut/debug/deps --emit=dep-info,link -L dependency=/home/alex/code/cargo/wut/debug/deps --cap-lints allow`
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
thread 'rustc' panicked at 'index out of bounds: the len is 382871 but the index is 382871', ../src/libserialize/leb128.rs:46
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: Could not compile `cfg-if`.
Caused by:
process didn't exit successfully: `rustc /home/alex/.cargo/registry/src/github.com-1ecc6299db9ec823/cfg-if-0.1.0/src/lib.rs --crate-name cfg_if --crate-type lib -g -C metadata=72c1f992b13d5087 -C extra-filename=-72c1f992b13d5087 --out-dir /home/alex/code/cargo/wut/debug/deps --emit=dep-info,link -L dependency=/home/alex/code/cargo/wut/debug/deps --cap-lints allow` (exit code: 101) When executing with
So what's happening here is:
So I take back what I said earlier about this likely being a Cargo bug, it seems like this may be a bug in the compiler trying to read stale metadata? I thought we had like 10 checks in place to ensure we didn't do that, but maybe it's still leaking through? |
I'm going to tag this as a stable-to-nightly regression as this appears to have been introduced in nightly. If I build cargo with beta and then switch to beta, the compiler doesn't ICE. |
The panic on stable happens in Did we change how we encode version information? cc @rust-lang/compiler |
I incremented the header version number though... It should be impossible for older rustc to get that far. |
Oh it looks like my changes have reached stable. I wonder if perhaps the |
Why is this even calling leb128? Are we using variable-length integers in the metadata header? |
@michaelwoerister I assumed leb128 was the crate being built, not one used by the compiler. |
Sure enough. Now every change to I think we should go back to JSON version guard. |
Ahh that's what it was. We can put it at the start then, before/after the |
What was the PR that modified the versioning scheme? I gather that something has changed about it. Can somebody explain more clearly what is going wrong here? |
@brson I mistakenly put the version string inside a larger The fix would be to separate it again, put it back at the start and leave it there. Or just encode/decode it before The PR that introduced the new schema was #36551, although breakage didn't happen until |
#37463 removed the field |
@alexcrichton @brson I believe I have a fix ready. Does this affect beta too now, or just nightly? |
@eddyb AFAIK it's just nightly, not beta or stable |
rustc_metadata: don't break the version check when CrateRoot changes. In #36551 I made `rustc_version` a field of `CrateRoot`, but despite it being the first field, one could still break the version check by changing `CrateRoot` so older compilers couldn't fully decode it (e.g. #37463). This PR fixes #37803 by moving the version string back at the beginning of metadata, right after the 32-bit big-endian absolute position of `CrateRoot`, and by incrementing `METADATA_VERSION`.
thread 'rustc' panicked at 'index out of bounds: the len is 37008 but the index is 37008', ../src/libserialize\leb128.rs:47
kind of expected, after switching toolchain from 1.15 back to 1.14. cargo clean && cargo build "repaired it"
The text was updated successfully, but these errors were encountered: