Skip to content
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

Merged
merged 3 commits into from
Oct 31, 2024

Conversation

weihanglo
Copy link
Member

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

@rustbot
Copy link
Collaborator

rustbot commented Oct 30, 2024

r? @ehuss

rustbot has assigned @ehuss.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-rebuild-detection Area: rebuild detection and fingerprinting S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 30, 2024
@@ -84,7 +84,7 @@ pub enum DepInfoPathType {
/// | len of key | key bytes | value exists? | len of value | value bytes |
Copy link
Contributor

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

Copy link
Contributor

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)

Copy link
Member Author

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.

Copy link
Member Author

@weihanglo weihanglo Oct 30, 2024

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.

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.
Copy link
Contributor

Feel free to r= me now or after resolving the nit

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`.
@weihanglo
Copy link
Member Author

@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.

@bors
Copy link
Contributor

bors commented Oct 30, 2024

📌 Commit 634450e has been approved by epage

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 30, 2024
@bors
Copy link
Contributor

bors commented Oct 30, 2024

⌛ Testing commit 634450e with merge de5832f...

@bors
Copy link
Contributor

bors commented Oct 31, 2024

☀️ Test successful - checks-actions
Approved by: epage
Pushing de5832f to master...

@bors bors merged commit de5832f into rust-lang:master Oct 31, 2024
22 checks passed
@weihanglo weihanglo deleted the depinfo-format branch October 31, 2024 00:32
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 2, 2024
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)
@rustbot rustbot added this to the 1.84.0 milestone Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rebuild-detection Area: rebuild detection and fingerprinting A-testing-cargo-itself Area: cargo's tests S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"memory allocation of .. bytes failed" appears when using cargo run test to run specific test name
5 participants