Closed icmccorm closed 6 months ago
@icmccorm Could you create PR with fix?
My apologies—I think my interpretation above was incorrect. Under the latest version of Tree Borrows (which fixes an issue with Frozen and Reserved permissions) there is no longer an error for this test case. I'll follow up with a pull request if I find anything else but for now I'll close this issue.
I've been experimenting with a version of Miri that can execute foreign functions by interpreting the LLVM bytecode that is produced during a crate's build process.
Miri found an instance of undefined behavior in aubio-rs at version 0.2.1 when running the test
filterbank::test::test_filterbank
.I believe this is because
FMat
is a self-referential structure. Consider the implementation ofFrom<T>
on line 427 of src/vec.rs:When
self.fmat.data
is read, it counts as a “foreign read access” under Tree Borrows, which makes the fieldself._x
have a read only permission. This means that whenself._x
is dropped, it counts as writing with a read-only permission, which is undefined behavior.To fix this, you would need to modify
FMat
to only retain a single reference toarray
instead of having botharray
anddata
as aliases.