Repository navigation
Fix memory leaks in unit tests - #523
Merged
Merged
Conversation
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can type 'qodo, fix this' on a finding and the fix lands right on your PR Powered by Qodo |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #523 +/- ##
=======================================
Coverage 72.38% 72.38%
=======================================
Files 31 31
Lines 8198 8198
=======================================
Hits 5934 5934
Misses 2264 2264 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
RUSTSEC-2026-0386 reports that `tokio::io::unix::AsyncFd` has safe constructors that accept any `T: AsRawFd`. Safe code can therefore build an `AsyncFd` from an arbitrary or closed file descriptor, and a closed and reused descriptor can lead to a use-after-free in the I/O driver. The advisory asks for Tokio 1.51.6, 1.53.3 or 1.54.0 and later, where those constructors are deprecated in favour of unsafe ones. This bumps the lockfile to 1.54.1. The driver does not call `AsyncFd` itself. Tokio is a dependency of rust-driver, so the fix is a lockfile update and nothing more. `cargo deny check` reports advisories, bans, licenses and sources all ok.
The unit tests leaked 11 allocations. None of them is a leak in the driver: every one is a test that creates an object through the C API and never frees it. They are invisible to `cargo test`, and they show up as soon as the suite runs under valgrind. - `test_typecheck_on_append_to_collection` builds a data type with `ArcFFI::into_ptr()` in seven blocks, and frees it in three of them. - `regression_empty_collection_data_type_test` never frees its collection. - `regression_empty_tuple_data_type_test` never frees its tuple. - `session_resolves_exec_profile_on_first_query` passes the result of `cass_session_execute()` straight into `cass_future_error_code()`, so the future is never freed. It does this four times. With these fixed, valgrind reports one remaining leak: the Tokio runtime, which the driver never drops on purpose. This makes it possible to run the unit tests under valgrind in the CI, as the C++ integration tests already are.
wprzytula
force-pushed
the
tmp/leakfix
branch
from
October 26, 2026 07:54
1bc50ec to
7eff2f1
Compare
Lorak-mmk
approved these changes
Oct 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The unit tests leaked 11 allocations. None of them is a leak in the driver: every one is a test that creates an object through the C API and never frees it. They are invisible to
cargo test, and they show up as soon as the suite runs under valgrind.test_typecheck_on_append_to_collectionbuilds a data type withArcFFI::into_ptr()in seven blocks, and frees it in three of them.regression_empty_collection_data_type_testnever frees its collection.regression_empty_tuple_data_type_testnever frees its tuple.session_resolves_exec_profile_on_first_querypasses the result ofcass_session_execute()straight intocass_future_error_code(), so the future is never freed. It does this four times.With these fixed, valgrind reports one remaining leak: the Tokio runtime, which the driver never drops on purpose.
This makes it possible to run the unit tests under valgrind in the CI, as the C++ integration tests already are.
Bonus
Tokio is updated to 1.54.1, following a cargo deny's advisory.
Pre-review checklist
[ ] I have provided docstrings for the public items that I want to introduce.[ ] I have adjusted the documentation in./docs/source/.[ ] I have implemented Rust unit tests for the features/changes introduced.[ ] I have enabled appropriate tests inMakefilein{SCYLLA,CASSANDRA}_(NO_VALGRIND_)TEST_FILTER.[ ] I added appropriateFixes:annotations to PR description.