angr icon indicating copy to clipboard operation
angr copied to clipboard

Fix bug in CFGUtils.quasi_topological_sort_nodes

Open lockshaw opened this issue 6 years ago • 11 comments

The previous implementation would return an empty list of nodes when given a cycle of two nodes. This fixes that.

lockshaw avatar Jul 13 '19 17:07 lockshaw

LGTM. Can you also add a test case of your observed failure case?

ltfish avatar Jul 13 '19 17:07 ltfish

Wow. That's a strange one! Thanks @lockshaw!

I can't check the "real" test case in here, but before I merge, I will add one to binaries-private

subwire avatar Jul 14 '19 20:07 subwire

Test is covered by, at least https://github.com/angr/angr/pull/1668

subwire avatar Jul 16 '19 03:07 subwire

Let's add a unit test before merging this in.

ltfish avatar Jul 16 '19 09:07 ltfish

@ltfish Sorry that took so long! Unit test added. Where does angr track test dependencies?

lockshaw avatar Sep 01 '19 19:09 lockshaw

@lockshaw Our dependencies are marked in setup.py. But, why are we adding adding this library for a single test? We already use nose for our unit testing, would it be possible for you implement the unit test using that rather than a whole new library?

twizmwazin avatar Sep 02 '19 05:09 twizmwazin

@twizmwazin Are test dependencies marked in setup.py? I imagine nose would be a pretty hard dependency for tests, and I see it referenced nowhere in that file.

Hypothesis is orthogonal to the nose. It would be possible to implement a similar test without it, but would require a non-trivial amount of code that we would then be responsible for maintaining, and would be lower quality than what hypothesis already offers. I added it because using it (ideally for more than just this test) should make bugs like this one a lot more rare. I've had good experiences using it over the last few months, if that counts for anything.

lockshaw avatar Sep 02 '19 13:09 lockshaw

Fair enough. It appears that we do not explicitly mark test dependencies up to this point. setuptools seems to support test dependencies, which would be installed when running python setup.py develop but not python setup.py install. We should probably add this to each project's setup.py.

twizmwazin avatar Sep 03 '19 02:09 twizmwazin

@twizmwazin Do you want to take care of that or should I? I'd like to get this fix merged

lockshaw avatar Sep 24 '19 21:09 lockshaw

I'll add the dependency to our install and rerun the tests.

twizmwazin avatar Sep 26 '19 23:09 twizmwazin

You'll want to rebase your branch on top of the latest master first. Some interfaces have changed.

ltfish avatar Sep 28 '19 06:09 ltfish