Fuzz collections for exception safety #18030
Labels
A-collections
Area: `std::collections`
A-testsuite
Area: The testsuite used to check the correctness of rustc
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
E-help-wanted
Call for participation: Help is requested to fix this issue.
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
It's easy to accidentally write something that's unsafe in the presence of unwinding, which is a problem if arbitrary user code is being run. This occurs in many methods inside data structures, e.g. ordered maps do many comparisons, calling the user defined
cmp
method (which could unwind), and theClone
implementations will callclone
on the contained data, which possibly unwinds.It would be a nice assurance to have these tested (exhaustively, if possible), e.g.
sort
is tested like this: it creates a random vector, counts how many comparisons are required to sort it, and the tests that failing on any of those comparisons is correct (which it checks by seeing that the destructors are run exactly once). It would be nice to do this with comparison-based data structures and especially the clone implementations.In the best case, we might have some sort of framework for this. E.g. a function like
f
would be called repeatedly with different values of the closureg
; the user calls that in the location that should fail. The first call off
will haveg
just counting how many calls, and later calls will haveg
failing after a certain number.That is, the
sort
test above could be written something like:(I guess
run_failure_test
it might need to take "setup" and "check" closures too.)The text was updated successfully, but these errors were encountered: