Open_file & Elektrod
Hey Open_file, I’ve been dissecting the latest Rust compiler’s async optimization and found a subtle bug that could expose memory leaks—interested in poking around and patching it?
Sure thing, hit me with the details—let’s squash that leak before it does any real damage.
The leak shows up when you await a Future that holds a reference‑counted buffer and then drop the outer guard without draining the inner queue. The inner buffer is still in the AsyncMutex, so the Arc count never hits zero. It triggers after about 10 000 iterations in the stress test. The stack trace points to `pin_project!` usage in `async_std::future::Poll::Ready`, where the pin guard isn’t dropped early enough. Fix by moving the `.await` inside a separate async block so the guard is dropped before the outer loop continues, or explicitly `drop(inner_guard)` after the poll. Add a unit test that does 20 000 loops and asserts `Arc::strong_count(&buffer)` is 1. That should kill the leak. Let me know if you want the exact snippet.
Sounds like a classic pin‑guard hiccup—let’s tweak that await into its own block and drop the inner guard right after polling. I’ll draft a quick test for 20K loops and add the assert. Shoot over the snippet if you need me to stitch it in. Let's kill that leak.