-
Notifications
You must be signed in to change notification settings - Fork 349
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
Memory leak checker misses AtomicPtr #1574
Comments
|
So... we can either not do a cast in |
Yeah, I cannot think of a good way to fix this I am afraid... we cannot just randomly cast any integer we see to a pointer in the off chance that it represents an actual address. Ideally Probably I should not have closed #1318, which is the same problem. Crossbeam is also affected by this (crossbeam-rs/crossbeam#464). Currently the best way to approach the problem is to call |
Oh, I like this. That seems entirely reasonable to me |
I was unable to find any recent information on this being true and changing it in rustc to just use pointers worked without any additional changes. |
Uh I thought I had LLVM experts confirm that when I asked but maybe I misremember. |
FWIW, this is also a problem when using |
Status: @oli-obk started some work on supporting raw pointer types in the atomic intrinsics in rust-lang/rust#77611, and then realized that this would need some support by the codegen backend since LLVM only supports atomic operations on integer types. |
Directly use raw pointers in `AtomicPtr` store/load I was unable to find any reason for this limitation in the latest source of LLVM or in the documentation [here](http://llvm.org/docs/Atomics.html#libcalls-atomic). fixes rust-lang/miri#1574
Just to double-check my understanding; is it expected that |
I'm also double-checking in rust-lang/miri#1574 (comment).
Yes. We need to fix this in libstd/rustc, miri is doing the right thing ™️ and implementing workarounds just on the miri side is not feasible afaict |
So looks like this comment was not accurate then?
|
@jonhoo looking at the So actually I think I disagree with Oli, this is not expected. Do you have a small example of this going wrong? |
Hmm, interesting.. What led me down this path wasn't directly related to the leak check, but rather I don't have a reduced test case at the moment, but the code is in https://github.com/jonhoo/haphazard/, and it's not very complicated and has no dependencies, so reducing to a simple test case shouldn't be too bad. What made me think a ptr-to-int conversion was happening was the "but parent tag " part of the Miri error from the test below, which matches the README's note saying " You can recognize false positives by
|
Yes, that message indicates an int-to-ptr cast. But the question is where that cast is happening... |
Anyway, AtomicPtr is likely innocent, so I will re-close this issue. Can you open a new issue for this problem? |
Ugh, looking through the code again, I realized that I do cast between pointers and integers to manage a bit in a pointer as a lock. That's unfortunate, but explains the problem. Sorry for the noise! Any news on whether Miri might gain capabilities for tracking pointers even in the presence of such casts and bit flips? Potentially with some extra code to tell Miri what's going on through an extern? These kinds of tricks are quite common in concurrency primitive libraries where Miri is invaluable. |
Please open a new issue with a pointer to the relevant code. :) |
Filed #1993 |
Miri considers memory leaks reachable through a static global as non-leaking. I'd expect the Atomic* case be non-leaking as well, however miri reports it as leaked memory.
(This is a special case of #1618.)
The text was updated successfully, but these errors were encountered: