From be5bee81c4116388f6f3626b6ce1089845c4f792 Mon Sep 17 00:00:00 2001 From: Steven Koo Date: Mon, 10 Aug 2020 17:36:45 -0500 Subject: rfnoc: Resolves streamer/link segfaults on python This commit resolves a segfault that occurs during teardown. Since teardown isn't detereministic in python, there were cases where the graph would destruct before the streamers or links got chance to cleanup. This would result in a segfault. This change gives the lambda a shared pointer to the object the callback method is calling on, so that it won't destruct before being called. --- host/lib/rfnoc/rfnoc_graph.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'host/lib/rfnoc/rfnoc_graph.cpp') diff --git a/host/lib/rfnoc/rfnoc_graph.cpp b/host/lib/rfnoc/rfnoc_graph.cpp index 027d27f81..2e90fb48f 100644 --- a/host/lib/rfnoc/rfnoc_graph.cpp +++ b/host/lib/rfnoc/rfnoc_graph.cpp @@ -442,15 +442,17 @@ public: uhd::rx_streamer::sptr create_rx_streamer( const size_t num_ports, const uhd::stream_args_t& args) { + auto this_graph = shared_from_this(); return std::make_shared( - num_ports, args, [this](const std::string& id) { this->disconnect(id); }); + num_ports, args, [this_graph](const std::string& id) { this_graph->disconnect(id); }); } uhd::tx_streamer::sptr create_tx_streamer( const size_t num_ports, const uhd::stream_args_t& args) { + auto this_graph = shared_from_this(); return std::make_shared( - num_ports, args, [this](const std::string& id) { this->disconnect(id); }); + num_ports, args, [this_graph](const std::string& id) { this_graph->disconnect(id); }); } size_t get_num_mboards() const -- cgit v1.2.3