From 5ea43897419aac8db824944abc764868232b45af Mon Sep 17 00:00:00 2001 From: Aaron Rossetto Date: Fri, 16 Oct 2020 09:19:26 -0500 Subject: graph: Re-fetch dst_node descriptor after src_node potential removal The graph_t::disconnect(src_node, dst_node) function removes connections (edges) from src_node to dst_node in the graph, and then removes the nodes (vertices) if their degree is zero after removing the connections. Because removing a vertex from the graph invalidates vertex descriptors, the graph_t::_remove_node() function resynchronizes the node-to-vertex descriptor map after removing the vertex. However, in graph_t::disconnect(), the vertex descriptor corresponding to dst_node was not being refetched after the potential removal of src_node, which results in the incorrect removal of innocent nodes under certain circumstances. This commit ensures that the node-to-vertex descriptor is reconsulted for the vertex descriptor corresponding to dst_node before removing it from the tree. --- host/lib/rfnoc/graph.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'host/lib/rfnoc') diff --git a/host/lib/rfnoc/graph.cpp b/host/lib/rfnoc/graph.cpp index d4f2d37e7..2edf591b3 100644 --- a/host/lib/rfnoc/graph.cpp +++ b/host/lib/rfnoc/graph.cpp @@ -200,6 +200,9 @@ void graph_t::disconnect(node_ref_t src_node, node_ref_t dst_node, graph_edge_t _remove_node(src_node); } + // Re-look up the vertex descriptor for dst_node, as the act of removing + // src_node may have modified it + dst_vertex_desc = _node_map.at(dst_node); if (boost::degree(dst_vertex_desc, _graph) == 0) { _remove_node(dst_node); } -- cgit v1.2.3