-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
fix: track version in fingerprint dep-info files #14751
Conversation
@@ -84,7 +84,7 @@ pub enum DepInfoPathType { | |||
/// | len of key | key bytes | value exists? | len of value | value bytes | |
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.
Should we also have a sanity-check value on "len of key" We likely should never have a dep info key that is larger than 10k for instance
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.
(and ture for any length we deal with)
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.
Not sure. What if they do track that many environment variables?
An allocation error seems reasonable in that case. Cargo may crash in other places even it doesn't here.
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.
An alternative is https://doc.rust-lang.org/nightly/std/vec/struct.Vec.html#method.try_with_capacity.
(not yet stable though)
though somehow the core dumpe happened with the first push, not when calling with_capacity
.
a2a2ad7
to
e4fac7a
Compare
We're going to add the magic marker in the next commit. The v0 test is to ensure that we don't change anything unexpected.
e4fac7a
to
5c17b23
Compare
Feel free to |
5c17b23
to
7e60ca4
Compare
Encodes the version information into Cargo's fingerprint dep-info files, so that when the format encoding changes in the future, Cargo understands a dep-info file was outdated and doesn't bother parsing it. Since there was no version info encoded in the old format (call it v0), to be compatible with older cargoes, this PR works around it with a horrible hack. It is explained in the doc comment of `EncodedDepInfo`.
7e60ca4
to
634450e
Compare
@bors r=epage While none of the test covers the OOM cases described in #14712, weihanglo#69 shows both failed and successful builds before and after this patch. |
☀️ Test successful - checks-actions |
Update cargo 18 commits in e75214ea4936d2f2c909a71a1237042cc0e14b07..0310497822a7a673a330a5dd068b7aaa579a265e 2024-10-25 16:34:32 +0000 to 2024-11-01 19:27:56 +0000 - Add more metadata to `rustc_fingerprint` (rust-lang/cargo#14761) - test(rustfix): switch to a simpler case for dedup-suggestions (rust-lang/cargo#14765) - chore(deps): update rust crate security-framework to v3 (rust-lang/cargo#14766) - chore(deps): update rust crate gix to 0.67.0 (rust-lang/cargo#14762) - fix(util): Respect all `..`s in `normalize_path` (rust-lang/cargo#14750) - test(doc): Resolve flaky test (rust-lang/cargo#14760) - refactor(test): Remove dead 'expect_stdout_contains_n' check (rust-lang/cargo#14759) - add unstable -Zroot-dir flag to configure the path from which rustc should be invoked (rust-lang/cargo#14752) - docs(resolver): Further v3 prep (rust-lang/cargo#14753) - fix: track version in fingerprint dep-info files (rust-lang/cargo#14751) - test: Remove unused msrv-policy (rust-lang/cargo#14748) - download targeted transitive deps of with artifact deps' target platform (rust-lang/cargo#14723) - Remove requirement for --target when invoking Cargo with -Zbuild-std (rust-lang/cargo#14317) - docs(fingerprint): document the encoding of Cargo's depinfo (rust-lang/cargo#14745) - Allow build scripts to report error messages through `cargo::error` (rust-lang/cargo#14743) - fix(publish): Downgrade version-exists error to warning on dry-run (rust-lang/cargo#14742) - fix: clean up for deprecated and removed commands (rust-lang/cargo#14739) - Deprecate `cargo verify-project` (rust-lang/cargo#14736)
What does this PR try to resolve?
Encodes the version information into Cargo's fingerprint dep-info files,
so that when the format encoding changes in the future,
Cargo understands a dep-info file was outdated and doesn't bother parsing it.
Since there was no version info encoded in the old format (call it v0),
to be compatible with older cargoes,
this PR works around it with a horrible hack.
It is explained in the doc comment of
EncodedDepInfo
.How should we test and review this PR?
This PR also adds a static file which is v0 depinfo,
to ensure newer cargoes give up parsing it successfully without allocation errors.
See the allocation failures in this CI job result: https://github.com/weihanglo/cargo/actions/runs/11601065840/job/32302943597
It is no harm to keep the v0 test file also fine with removing it from git.
Additional information
Fixes #14712