[Storage] remove download_into#4166
Merged
jaschrep-msft merged 3 commits intoAzure:mainfrom Apr 17, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Removes the BlobClient::download_into API (and its internal implementation/tests) due to unsoundness when the async future is dropped, avoiding unsafe cross-thread borrowed buffer usage.
Changes:
- Removed
BlobClient::download_intopublic API and the partitioned-transfer implementation that wrote into&mut [u8]. - Deleted
SendSlice(unsafeSendwrapper over raw slice pointers) and its module wiring. - Removed unit/integration tests that exercised
download_into.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| sdk/storage/azure_storage_blob/tests/blob_client.rs | Removes recorded integration tests that depended on download_into. |
| sdk/storage/azure_storage_blob/src/partitioned_transfer/download.rs | Deletes unsafe download_into implementation and related worker helpers/tests. |
| sdk/storage/azure_storage_blob/src/models/slice.rs | Removes SendSlice definition that enabled sending borrowed buffers across threads. |
| sdk/storage/azure_storage_blob/src/models/mod.rs | Drops the slice module export after deletion. |
| sdk/storage/azure_storage_blob/src/clients/blob_client.rs | Removes the public download_into method from BlobClient. |
02ebfa4 to
abd5523
Compare
Member
Author
|
@heaths @LarryOsterman it seems semver checks are now in CI. We haven't technically GA'd yet and this method has serious memory safety concerns. How can we get this through? |
abd5523 to
31d9897
Compare
jalauzon-msft
approved these changes
Apr 17, 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.
download_intocurrently cannot account for its unsafe use of pointers when its future is dropped. It is being removed for now to return in a future release.Streaming
downloaddoes not encounter this issue, as it owns all its memory.The Problem
To achieve the desired performance, managed downloads spawn workers in the async runtime which do the work of individual downloads into memory.
download_intomust write bytes directly into&mut [u8], which cannot be safely sent over a thread boundary.However, these workers are not contained in the
Futures which reference them. Those are only join handles. Dropping them does not stop the thread, it only loses any reference to its results.This is already accounted for in the event of a failure. The async function does not return without forcing every thread to join, ensuring no stray references to memory that disobeys borrow rules. Dropping the future for this async function bypasses that.
Future Solutions
Assuming we will continue to use borrowed memory and continue to spawn workers, the solution is likely to write a
Dropimplementation that will go off when the async future is dropped. Thisdrop()will be responsible for guaranteeing no further work is done with the borrowed memory.