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

failed to mmap rmeta metadata #89795

Closed
ehuss opened this issue Oct 12, 2021 · 3 comments · Fixed by #90072
Closed

failed to mmap rmeta metadata #89795

ehuss opened this issue Oct 12, 2021 · 3 comments · Fixed by #90072
Labels
C-bug Category: This is a bug.

Comments

@ehuss
Copy link
Contributor

ehuss commented Oct 12, 2021

Since #89634, rustc has been spewing this warning:

WARN rustc_metadata::locator no metadata found: failed to mmap rmeta metadata: '/home/eric/Proj/rust/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_ast-83f5770a611ead91.rmeta'

This happens particularly when using -L to load a sysroot crate, and using --emit metadata. This can happen with x.py check (using latest master as stage0 rustc), though I imagine it can happen in other scenarios. x.py check uses cargo's --all-targets which ends up including tests in the checks.

Reproduction:

touch shared.rs
rustc shared.rs --crate-type=dylib
rustc shared.rs --test --emit=metadata
echo "extern crate shared;" > a.rs
rustc a.rs --crate-type=rlib -L .

The cause of this particular error is that memmap2 0.2.1 returns an error it attempts to mmap a file of 0 length (though IIRC, the behavior is platform-specific). .rmeta files produced for binaries (such as with --test) have 0 length (#67293).

Possible Solutions

  • Update memmap2 to 0.5.0, which does not return an error for 0 sized files. However, the rest of the crate loading code would need to be updated, as it then generates an error since the file is missing the metadata header.
  • Skip rmeta files that are empty in crate loading.
  • Downgrade that warn! to info! or debug!

Meta

rustc --version --verbose:

rustc 1.57.0-nightly (41dfaaa3c 2021-10-10)
binary: rustc
commit-hash: 41dfaaa3c66759395835b3af59b22f4f22175dc8
commit-date: 2021-10-10
host: x86_64-unknown-linux-gnu
release: 1.57.0-nightly
LLVM version: 13.0.0
@ehuss ehuss added the C-bug Category: This is a bug. label Oct 12, 2021
@petrochenkov
Copy link
Contributor

cc #88368

This is not an erroneous situation, the warn! is "overreacting".
I'd personally remove this logging, but @bjorn3 asked to keep it in #88368 (comment), so demoting it to info!/debug! is also an alternative.

@bjorn3
Copy link
Member

bjorn3 commented Oct 12, 2021

I think ignoring 0 sized rmeta files specifically is fine. I would prefer to keep it a warning for bigger files. In any case please don't make it a debug!(). That requires recompiling rustc to be able to enable it.

nicholasbishop added a commit to nicholasbishop/uefi-rs that referenced this issue Oct 15, 2021
This test is failing in nightly due to:
rust-lang/rust#89795

Disabling the test for now to get the CI happy again. Will keep
rust-osdev#299 open as a reminder to
re-enable the test once the underlying issue has been fixed.
nicholasbishop added a commit to rust-osdev/uefi-rs that referenced this issue Oct 15, 2021
This test is failing in nightly due to:
rust-lang/rust#89795

Disabling the test for now to get the CI happy again. Will keep
#299 open as a reminder to
re-enable the test once the underlying issue has been fixed.
@gilescope
Copy link
Contributor

get_metadata_section's error is a String at the moment. That would need to be changed to an enum so that we can match on the right sort of error. If we uncompress something and its 0 long that presumably wants to stay as a warning...

@bors bors closed this as completed in 40ebd07 Oct 21, 2021
nicholasbishop added a commit to nicholasbishop/uefi-rs that referenced this issue Oct 27, 2021
This reverts commit a4f4fd2. The
upstream issue that was causing these tests to fail has been fixed:
rust-lang/rust#89795

Fixes rust-osdev#299
nicholasbishop added a commit to rust-osdev/uefi-rs that referenced this issue Oct 27, 2021
This reverts commit a4f4fd2. The
upstream issue that was causing these tests to fail has been fixed:
rust-lang/rust#89795

Fixes #299
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 4, 2021
…henkov

Demote metadata load warning to "info".

There is a warn log message for whenever the crate loader fails to load metadata from a candidate file. I think this warning is too aggressive, as there are several situations where metadata information might not be found in a candidate file, which is normal. Also, this warning is somewhat confusing, and non-actionable in most cases for a user (most users will not know what it means).

If the crate loader ultimately does not find a valid crate, then an error will be reported (and hopefully rust-lang#88368 will improve that error message).

If a rustc developer wants to debug a loader problem, they can still use `RUSTC_LOG=rustc_metadata=debug` and get the details.

There is more discussion of this particular warning at rust-lang#89795 (comment).

Fixes rust-lang#90525
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 4, 2021
…henkov

Demote metadata load warning to "info".

There is a warn log message for whenever the crate loader fails to load metadata from a candidate file. I think this warning is too aggressive, as there are several situations where metadata information might not be found in a candidate file, which is normal. Also, this warning is somewhat confusing, and non-actionable in most cases for a user (most users will not know what it means).

If the crate loader ultimately does not find a valid crate, then an error will be reported (and hopefully rust-lang#88368 will improve that error message).

If a rustc developer wants to debug a loader problem, they can still use `RUSTC_LOG=rustc_metadata=debug` and get the details.

There is more discussion of this particular warning at rust-lang#89795 (comment).

Fixes rust-lang#90525
JohnTitor added a commit to JohnTitor/rust that referenced this issue Nov 5, 2021
…henkov

Demote metadata load warning to "info".

There is a warn log message for whenever the crate loader fails to load metadata from a candidate file. I think this warning is too aggressive, as there are several situations where metadata information might not be found in a candidate file, which is normal. Also, this warning is somewhat confusing, and non-actionable in most cases for a user (most users will not know what it means).

If the crate loader ultimately does not find a valid crate, then an error will be reported (and hopefully rust-lang#88368 will improve that error message).

If a rustc developer wants to debug a loader problem, they can still use `RUSTC_LOG=rustc_metadata=debug` and get the details.

There is more discussion of this particular warning at rust-lang#89795 (comment).

Fixes rust-lang#90525
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants