Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert change to reindex_edge_list. #269

Merged
merged 6 commits into from
Feb 21, 2022

Conversation

cqc-alec
Copy link
Contributor

@cqc-alec cqc-alec commented Jul 2, 2021

Fixes #268 .

Revert change to `reindex_edge_list`.

See boostorg#268 .
Copy link

@prince-chrismc prince-chrismc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to keep the for loop and remove the increments if you correctly update after the erease

{
if (ei->get_target() > u)
{
typename EdgeList::value_type ce = *ei;
++ei;
el.erase(ce);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
el.erase(ce);
ei = el.erase(ce);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. It indeed looks like a better approach; however, I was not able to get this code to compile:

#include <boost/graph/adjacency_list.hpp>

using Graph = boost::adjacency_list<boost::setS, boost::vecS, boost::undirectedS>;

int main() {
  Graph g(3);
  boost::add_edge(2, 0, g);
  boost::remove_vertex(1, g);
}

The gist of the error is that erase does not return an iterator in this case, but a long unsigned int.

(The original patch was simply a reversion of a previous commit.)

@jeremy-murphy
Copy link
Contributor

Could you please add the example from the bug report that can trigger this segfault as a new unit test?
As long as it is reliable under valgrind or a memory sanitizer, that is sufficient.

@cqc-alec
Copy link
Contributor Author

cqc-alec commented Dec 9, 2021

Could you please add the example from the bug report that can trigger this segfault as a new unit test? As long as it is reliable under valgrind or a memory sanitizer, that is sufficient.

Yes, I will do.

@cqc-alec
Copy link
Contributor Author

I have added the unit test to delete_edge.cpp, which seems the most appropriate existing test file -- is that OK or would you prefer a new source file?

@jeremy-murphy
Copy link
Contributor

I have added the unit test to delete_edge.cpp, which seems the most appropriate existing test file -- is that OK or would you prefer a new source file?

I think the location is fine.

Is there a reason that you can't use the existing m_graph object? I know the MWE given uses undirected edges but the explanation does not stipulate it. Hmm. Anyway, it's probably good to test on both directed and undirected.

I know that we're primarily testing for a segfault, but it looks weird in a test if there is no accompanying assertion, so please add in a BOOST_TEST for i) the expected number of vertices and ii) edges after calling remove_vertex.

Thank you!!

@jeremy-murphy
Copy link
Contributor

Looks great, thanks. As soon as the CI is fixed, I'll merge this.

@jeremy-murphy jeremy-murphy self-assigned this Jan 5, 2022
@jeremy-murphy
Copy link
Contributor

Please update to the latest changes on develop so we can test for a green build.

@cqc-alec
Copy link
Contributor Author

cqc-alec commented Feb 4, 2022

Please update to the latest changes on develop so we can test for a green build.

Done. Still seems to be one build failure (looks unrelated) ...?

@jeremy-murphy
Copy link
Contributor

jeremy-murphy commented Feb 5, 2022

Yeah, that is strange and annoying.

@jeremy-murphy
Copy link
Contributor

Might be a real issue with Boost.Filesystem, let's see: boostorg/filesystem#227

@jeremy-murphy
Copy link
Contributor

jeremy-murphy commented Feb 8, 2022

The simplest way I know to re-run the CI is to close the PR and open it again!

@jeremy-murphy
Copy link
Contributor

Hmmm, that didn't work as I expected.

@jeremy-murphy
Copy link
Contributor

A couple of issues have been fixed so I think if you merge develop now, you should get a green build.

@cqc-alec
Copy link
Contributor Author

A couple of issues have been fixed so I think if you merge develop now, you should get a green build.

Done: seems good now!

@jeremy-murphy jeremy-murphy merged commit fa3bd05 into boostorg:develop Feb 21, 2022
@jeremy-murphy
Copy link
Contributor

Awesome!

In the future, I think it's good to refer to the commit that you're reverting (I put it in the merge commit), so that people can easily track the history.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Segfault for remove_vertex with adjacency_list<boost::setS, ...>
3 participants