Function algorithm::isolate removes edges while iterating over the neighbors of u. The neighbors iterator should, in theory, be invalidated since removing an edge with u would modify the neighbors of u. It seems to work though because the underlying Nauty set doesn't change its size and pointers are not invalidated after DELELEMENT.
We should not even be allowed to write this code because Rust should see it. However, since GraphIter::neighbors doesn't take a lifetime specification, and the GraphNauty::neighbors implementation uses unsafe, this bug slipped through the cracks.
This code is allowed and is actually completely wrong:
Function
algorithm::isolate
removes edges while iterating over the neighbors ofu
. The neighbors iterator should, in theory, be invalidated since removing an edge withu
would modify the neighbors ofu
. It seems to work though because the underlying Nauty set doesn't change its size and pointers are not invalidated afterDELELEMENT
.We should not even be allowed to write this code because Rust should see it. However, since
GraphIter::neighbors
doesn't take a lifetime specification, and theGraphNauty::neighbors
implementation uses unsafe, this bug slipped through the cracks.This code is allowed and is actually completely wrong: