Repository navigation
SoapyPlutoSDR: close remaining streams during device teardown - #81
Merged
Merged
Conversation
This ensure that unclosed streams are always closed when destroying the device. Otherwise, the streams's destructors will be called after iio_context_destroy, which will cause a segfault.
Member
|
Sensible to do, yes. Thanks! |
ATG-wdorsey
added a commit
to ATG-wdorsey/SoapyPlutoSDR
that referenced
this pull request
Oct 21, 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.
Hi, this PR to ensure that unclosed streams are always closed when destroying the device.
Otherwise, the streams's destructors will be called after
iio_context_destroy, which will cause a segfault and (probably) not correctly release hw resources.Details
Close any remaining RX and TX streams before destroying the libiio context.
This ensure that unclosed streams are always closed when destroying the device, otherwise, the streams's destructors will be called after
iio_context_destroy, which will cause a segfault.SoapyPlutoSDRowns its streamers throughstd::unique_ptrmembers, butC++ destroys those members only after the device destructor body finishes.
The destructor currently destroys the IIO context first, so any remaining
streamer can subsequently attempt to destroy buffers or disable channels
whose context is no longer valid.
Call the existing
closeStream()implementation for each remaining streamwhile the IIO context is still valid. This releases the streamer resources
in the correct order and performs the normal stream-close cleanup,
including powering down the corresponding LO.
This change provides defensive cleanup when applications don't close their streams explicitly.
Reproduction
Release a PlutoSDR device while a stream remains allocated, for exemple using srsRAN's
cell_search:With the unmodified plugin, reception succeeded, but the process then
crashed during teardown in
iio_buffer_destroy().