aboutsummaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorSteven Koo <steven.koo@ni.com>2020-08-10 17:36:45 -0500
committerAaron Rossetto <aaron.rossetto@ni.com>2020-08-11 16:07:40 -0500
commitbe5bee81c4116388f6f3626b6ce1089845c4f792 (patch)
tree071d3a017575b2a43caf95515c74426305b54882 /host
parentfc3f91e0cfb77e295673ac04d310ded65863c119 (diff)
downloaduhd-be5bee81c4116388f6f3626b6ce1089845c4f792.tar.gz
uhd-be5bee81c4116388f6f3626b6ce1089845c4f792.tar.bz2
uhd-be5bee81c4116388f6f3626b6ce1089845c4f792.zip
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.
Diffstat (limited to 'host')
-rw-r--r--host/include/uhd/rfnoc_graph.hpp2
-rw-r--r--host/lib/rfnoc/rfnoc_graph.cpp6
-rw-r--r--host/lib/usrp/mpmd/mpmd_mb_iface.cpp23
-rw-r--r--host/lib/usrp/x300/x300_mb_iface.cpp26
4 files changed, 33 insertions, 24 deletions
diff --git a/host/include/uhd/rfnoc_graph.hpp b/host/include/uhd/rfnoc_graph.hpp
index fabee53c7..e51fc3d83 100644
--- a/host/include/uhd/rfnoc_graph.hpp
+++ b/host/include/uhd/rfnoc_graph.hpp
@@ -29,7 +29,7 @@ class mb_controller;
* session, but also manages the RFNoC blocks on those devices. Only devices
* compatible with a modern version of RFNoC can be addressed by this class.
*/
-class UHD_API rfnoc_graph : public uhd::noncopyable
+class UHD_API rfnoc_graph : public uhd::noncopyable, public std::enable_shared_from_this<rfnoc_graph>
{
public:
/*! A shared pointer to allow easy access to this class and for
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<rfnoc_rx_streamer>(
- 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<rfnoc_tx_streamer>(
- 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
diff --git a/host/lib/usrp/mpmd/mpmd_mb_iface.cpp b/host/lib/usrp/mpmd/mpmd_mb_iface.cpp
index 534d71a4d..a24be5c57 100644
--- a/host/lib/usrp/mpmd/mpmd_mb_iface.cpp
+++ b/host/lib/usrp/mpmd/mpmd_mb_iface.cpp
@@ -176,6 +176,7 @@ uhd::rfnoc::chdr_ctrl_xport::sptr mpmd_mboard_impl::mpmd_mb_iface::make_ctrl_tra
recv_link, send_link, transport::link_type_t::CTRL);
auto pkt_factory = _link_if_mgr->get_packet_factory(link_idx);
+ auto io_srv_mgr = this->get_io_srv_mgr();
auto xport = uhd::rfnoc::chdr_ctrl_xport::make(io_srv,
send_link,
recv_link,
@@ -183,8 +184,8 @@ uhd::rfnoc::chdr_ctrl_xport::sptr mpmd_mboard_impl::mpmd_mb_iface::make_ctrl_tra
local_epid,
send_link->get_num_send_frames(),
recv_link->get_num_recv_frames(),
- [this, send_link, recv_link]() {
- this->get_io_srv_mgr()->disconnect_links(recv_link, send_link);
+ [io_srv_mgr, send_link, recv_link]() {
+ io_srv_mgr->disconnect_links(recv_link, send_link);
});
return xport;
}
@@ -242,6 +243,7 @@ mpmd_mboard_impl::mpmd_mb_iface::make_rx_data_transport(
// Create the data transport
auto pkt_factory = _link_if_mgr->get_packet_factory(link_idx);
+ auto io_srv_mgr = this->get_io_srv_mgr();
auto fc_params = chdr_rx_data_xport::configure_sep(cfg_io_srv,
recv_link,
send_link,
@@ -254,8 +256,8 @@ mpmd_mboard_impl::mpmd_mb_iface::make_rx_data_transport(
fc_freq,
fc_headroom,
lossy_xport,
- [this, recv_link, send_link]() {
- this->get_io_srv_mgr()->disconnect_links(recv_link, send_link);
+ [io_srv_mgr, recv_link, send_link]() {
+ io_srv_mgr->disconnect_links(recv_link, send_link);
});
cfg_io_srv.reset();
@@ -275,8 +277,8 @@ mpmd_mboard_impl::mpmd_mb_iface::make_rx_data_transport(
epids,
recv_link->get_num_recv_frames(),
fc_params,
- [this, recv_link, send_link]() {
- this->get_io_srv_mgr()->disconnect_links(recv_link, send_link);
+ [io_srv_mgr, recv_link, send_link]() {
+ io_srv_mgr->disconnect_links(recv_link, send_link);
});
return rx_xport;
@@ -319,6 +321,7 @@ mpmd_mboard_impl::mpmd_mb_iface::make_tx_data_transport(
recv_link, send_link, transport::link_type_t::CTRL);
auto pkt_factory = _link_if_mgr->get_packet_factory(link_idx);
+ auto io_srv_mgr = this->get_io_srv_mgr();
const auto buff_capacity = chdr_tx_data_xport::configure_sep(cfg_io_srv,
recv_link,
send_link,
@@ -329,8 +332,8 @@ mpmd_mboard_impl::mpmd_mb_iface::make_tx_data_transport(
mdata_buff_fmt,
fc_freq_ratio,
fc_headroom_ratio,
- [this, recv_link, send_link]() {
- this->get_io_srv_mgr()->disconnect_links(recv_link, send_link);
+ [io_srv_mgr, recv_link, send_link]() {
+ io_srv_mgr->disconnect_links(recv_link, send_link);
});
cfg_io_srv.reset();
@@ -351,8 +354,8 @@ mpmd_mboard_impl::mpmd_mb_iface::make_tx_data_transport(
epids,
send_link->get_num_send_frames(),
buff_capacity,
- [this, recv_link, send_link]() {
- this->get_io_srv_mgr()->disconnect_links(recv_link, send_link);
+ [io_srv_mgr, recv_link, send_link]() {
+ io_srv_mgr->disconnect_links(recv_link, send_link);
});
return tx_xport;
diff --git a/host/lib/usrp/x300/x300_mb_iface.cpp b/host/lib/usrp/x300/x300_mb_iface.cpp
index a6d5e794b..c89374f82 100644
--- a/host/lib/usrp/x300/x300_mb_iface.cpp
+++ b/host/lib/usrp/x300/x300_mb_iface.cpp
@@ -110,7 +110,7 @@ uhd::rfnoc::chdr_ctrl_xport::sptr x300_impl::x300_mb_iface::make_ctrl_transport(
auto io_srv =
get_io_srv_mgr()->connect_links(recv_link, send_link, link_type_t::CTRL);
-
+ auto io_srv_mgr = this->get_io_srv_mgr();
auto xport = chdr_ctrl_xport::make(io_srv,
send_link,
recv_link,
@@ -118,8 +118,8 @@ uhd::rfnoc::chdr_ctrl_xport::sptr x300_impl::x300_mb_iface::make_ctrl_transport(
local_epid,
send_link->get_num_send_frames(),
recv_link->get_num_recv_frames(),
- [this, send_link, recv_link]() {
- this->get_io_srv_mgr()->disconnect_links(recv_link, send_link);
+ [io_srv_mgr, send_link, recv_link]() {
+ io_srv_mgr->disconnect_links(recv_link, send_link);
});
return xport;
}
@@ -174,6 +174,8 @@ uhd::rfnoc::chdr_rx_data_xport::uptr x300_impl::x300_mb_iface::make_rx_data_tran
auto cfg_io_srv =
get_io_srv_mgr()->connect_links(recv_link, send_link, link_type_t::CTRL);
+ auto io_srv_mgr = this->get_io_srv_mgr();
+
auto fc_params = uhd::rfnoc::chdr_rx_data_xport::configure_sep(cfg_io_srv,
recv_link,
send_link,
@@ -186,8 +188,8 @@ uhd::rfnoc::chdr_rx_data_xport::uptr x300_impl::x300_mb_iface::make_rx_data_tran
fc_freq,
fc_headroom,
lossy_xport,
- [this, recv_link, send_link]() {
- this->get_io_srv_mgr()->disconnect_links(recv_link, send_link);
+ [io_srv_mgr, recv_link, send_link]() {
+ io_srv_mgr->disconnect_links(recv_link, send_link);
});
cfg_io_srv.reset();
@@ -208,8 +210,8 @@ uhd::rfnoc::chdr_rx_data_xport::uptr x300_impl::x300_mb_iface::make_rx_data_tran
epids,
recv_link->get_num_recv_frames(),
fc_params,
- [this, recv_link, send_link]() {
- this->get_io_srv_mgr()->disconnect_links(recv_link, send_link);
+ [io_srv_mgr, recv_link, send_link]() {
+ io_srv_mgr->disconnect_links(recv_link, send_link);
});
return rx_xport;
@@ -250,6 +252,8 @@ uhd::rfnoc::chdr_tx_data_xport::uptr x300_impl::x300_mb_iface::make_tx_data_tran
auto cfg_io_srv =
get_io_srv_mgr()->connect_links(recv_link, send_link, link_type_t::CTRL);
+ auto io_srv_mgr = this->get_io_srv_mgr();
+
const auto buff_capacity = chdr_tx_data_xport::configure_sep(cfg_io_srv,
recv_link,
send_link,
@@ -260,8 +264,8 @@ uhd::rfnoc::chdr_tx_data_xport::uptr x300_impl::x300_mb_iface::make_tx_data_tran
mdata_buff_fmt,
fc_freq_ratio,
fc_headroom_ratio,
- [this, recv_link, send_link]() {
- this->get_io_srv_mgr()->disconnect_links(recv_link, send_link);
+ [io_srv_mgr, recv_link, send_link]() {
+ io_srv_mgr->disconnect_links(recv_link, send_link);
});
cfg_io_srv.reset();
@@ -282,8 +286,8 @@ uhd::rfnoc::chdr_tx_data_xport::uptr x300_impl::x300_mb_iface::make_tx_data_tran
epids,
send_link->get_num_send_frames(),
buff_capacity,
- [this, recv_link, send_link]() {
- this->get_io_srv_mgr()->disconnect_links(recv_link, send_link);
+ [io_srv_mgr, recv_link, send_link]() {
+ io_srv_mgr->disconnect_links(recv_link, send_link);
});
return tx_xport;