Fix memory leak in rx_samples_c error cleanup waterfall#931
Open
tlozs wants to merge 1 commit into
Open
Conversation
|
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
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.
Pull Request Details
examples: fix memory leak in rx_samples_c cleanup
Description
This PR fixes an architectural flaw in the
gotocleanup waterfall within therx_samples_cexample.Previously, the
free_rx_streamerlabel was positioned above thefree_rx_metadatalabel. Because C executes sequentially, if an error occurred after the metadata was successfully created (for example, duringuhd_usrp_set_rx_rateoruhd_usrp_get_rx_stream), the code would jump tofree_rx_metadata, fall through tofree_usrp, and exit. It completely skippedfree_rx_streamer, silently leaking the streamer memory and leaving the hardware handles dangling.Changes:
EXECUTE_OR_GOTOjump targets for the stream setup functions to match the new waterfall order.Related Issue
N/A
Which devices/areas does this affect?
This affects the C API examples (
host/examples/rx_samples_c.c). This is a software-level logic fix and is device-agnostic.Testing Done
Verified that the updated example compiles successfully. The execution path of the error waterfall was manually traced to guarantee that all UHD handles are safely freed in the correct reverse-chronological sequence upon an initialization failure, eliminating the memory leak and preventing the freeing of unallocated memory.
Checklist
MPM compat, noc_shell, specific RFNoC block, ...)