-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Valgrind reports memory leak in runtime with current beta compiler #138430
Labels
C-bug
Category: This is a bug.
regression-from-stable-to-beta
Performance or correctness regression from stable to beta.
Comments
Might be a duplicate of #135608. |
I think this is #135608 indeed. |
Closing as a duplicate of #135608, thanks for the report. |
jfrimmel
added a commit
to jfrimmel/cargo-valgrind
that referenced
this issue
Mar 31, 2025
## Background Valgrind may detect leaks in the Rust standard library as it has done in the past (e.g. [here][rust1.83] and [here][beta]). Those "leaks" report- ed by Valgrind are not considered as leaks by the Rust team when they are small permanent allocation, which is not growing (as described [here][comment-1]) and there is no guarantee, that the Rust standard library is free of memory leaks (as described [here][comment-2]). There- fore some reports of Valgrind are entirely non-actionable by a user of this crate. In order to solve this, this PR addds a list of suppressions for the Rust `std`. Those are applied automatically, so that those "leaks" are never reported to the user. New suppressions should be added when leaks are detected in the [periodic test against the beta compiler][beta-job], but only after reporting them to the [Rust team][new-rust-issue] as documented in the new `suppressions/README.md`. The implementation is conceptually simple, but a bit tricky in the im- plementation: the suppression files are added to the `suppressions`-di- rectory and should be used by `cargo-valgrind` when running. But that directory is not available at runtime. Therefore the files need to be embedded into the binary. This is done by two co-working parts: 1. the build script, which reads all files in the `suppressions`-folder and writes their contents to a constant string `SUPPRESSIONS` and 2. the runtime code which crates a temporary file containing the afore- mentioned constant string. This file is then used as the argument to the `--suppressions`-option. [rust1.83]: rust-lang/rust#133574 [beta]: rust-lang/rust#138430 [comment-1]: rust-lang/rust#133574 (comment) [comment-2]: rust-lang/rust#135608 (comment) [beta-job]: https://github.com/jfrimmel/cargo-valgrind/actions/workflows/beta.yaml [new-rust-issue]: https://github.com/rust-lang/rust/issues/new?template=regression.md
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.
regression-from-stable-to-beta
Performance or correctness regression from stable to beta.
I maintain the
cargo-valgrind
-crate, which is a wrapper for running binaries & tests automatically within valgrind for memory analysis. As a sanity check, a periodic job runs some basic smoke tests against the current beta compiler. This smoke test was recently triggered, indicating a regression. In order to outrule the aforementioned tool, I present a reproducer with plain valgrind invocations below.Code
I tried the default test code generated by
cargo new --lib
:I expected to see this happen: when running the tests inside valgrind, no memory errors/leaks should be reported. This can be tested using the following commands:
There are no leaks reported with the current stable compiler (see version info below).
Instead, this happened: when performing the same commands with the current beta compiler (see version info below), there is a leak reported:
Version it worked on
It most recently worked on: Rust 1.85
rustc --version --verbose
:Version with regression
rustc +beta --version --verbose
:Also happens with the current nightly:
rustc +nightly --version --verbose
:@rustbot modify labels: +regression-from-stable-to-beta -regression-untriaged
The text was updated successfully, but these errors were encountered: