-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Unfreed (but still reachable) allocations in std::io::stdin are reported by Valgrind if non-default --show-leak-kinds=all
option is specified
#80406
Comments
rustc 1.48.0-nightly (623fb90 2020-09-26) Commits in that range: 623fb90...7f7a1cb |
I'm a bit busy right now. I'll look at it later, but I think this is a false positive (leaked on purpose). |
Before that change, the buffer for standard input was deallocated in an |
@m-ou-se That's still somewhat problematic; people use valgrind to track down leaks, and intentional leaks make that harder. We could address this via a patch to valgrind's standard "suppressions" mechanism. |
First, this memory is still reachable, so it's not a true leak. You have to run Valgrind with Having said that, Valgrind has a number of built-in suppressions for still-reachable "leaks" of this kind in system libraries, so it would be reasonable to add one for this case. I am happy to do that, so I have assigned this issue to me. Note that the fix will be in Valgrind, rather than in Rust. Also, Valgrind releases are unfortunately somewhat infrequent, so this change will almost certainly hit a Rust release before any fix makes it into a Valgrind release. |
@nnethercote Thank you for clarifying the nature of the valgrind warning here; I agree that we should worry less about "reachable" leaks, though we should add a suppression for them. I'd like to avoid "unreachable" leaks that valgrind would flag by default, and not just suppress those. |
Yes, these are "true" memory leaks and should be fixed in any code under our control. |
--show-leak-kinds=all
option is specified
Oh, I overlooked the fact that this PR is over a year old. I guess the lack of additional comments confirms that it's something of a niche issue. |
There's a Valgrind bug that's making this one hard to fix: https://bugs.kde.org/show_bug.cgi?id=452058 It affects suppressions involving inlined stack frame, which are possibly more common in Rust code than C/C++ code due to rustc's aggressive use of inlining. |
There was a memory leak introduced in between
nightly-2020-09-27
andnightly-2020-09-28
.If you build this code with two different toolchains one will have a memory leak and the other not.
this code built with nightly-2020-09-28
valgrind output
while this code built with nightly-2020-09-27:
valgrind output
valgrind --leak-check=full --show-leak-kinds=all
The text was updated successfully, but these errors were encountered: