CrossHair icon indicating copy to clipboard operation
CrossHair copied to clipboard

Avoid weakref nondeterminism

Open pschanely opened this issue 1 year ago • 1 comments

Weak references are inherently non-deterministic. CrossHair right now does nothing special to address this, and so it'll likely raise NotDeterministic when executing such code.

This issue (or maybe just a related one) is visible right now as a hypothesis test failure at tests/cover/test_filter_rewriting.py::test_regex_filter_rewriting. (via an unstable iteration order while trying to intercept a dictionary access for LAMBDA_SOURCE_CACHE in src/hypothesis/internal/reflection.py. Note that this is a global.

Probably the (easiest?) path forward is to intercept all weak accesses and make all values appear to be missing. Though then we'll miss bugs where returning a prior result reveals an issue. These paths should be marked incomplete, and should be subject to re-execution per #309.

pschanely avatar Oct 05 '24 16:10 pschanely

As of 0.0.74, there is (incomplete) support for making weakrefs be universally missing. You can check these weakref tests for up-to-date information on our level of support.

pschanely avatar Oct 09 '24 16:10 pschanely