Skip to content

Race condition error in recursive_property #4475

@Liam-DeVoe

Description

@Liam-DeVoe

Part of #4451. I have seen this error rarely when testing with multiple threads. As a debugging measure, I added a per-name lock around the entirety of recursive_property, but still saw this occur. My guess is a race in mapping somehow, such that a strategy doesn't get the cache_key set when we expect it to. But I'm not sure how this could happen.

Keywords for searchers: cached_is_empty, cached_is_cacheable.

 ~/Desktop/Liam/coding/hypothesis λ PYTEST_RUN_PARALLEL_VERBOSE=1 p1 -k test_intervalset --parallel-threads 2 -s --hypothesis-profile=threading

 ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― test_error_for_index_of_not_present_value ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
Traceback (most recent call last):
  File "/Users/tybug/Desktop/Liam/coding/hypothesis/hypothesis-python/tests/cover/test_intervalset.py", line 43, in test_error_for_index_of_not_present_value
    @example(intervals=IntervalSet(()), v=0)
                   ^^^
  File "/Users/tybug/Desktop/Liam/coding/hypothesis/hypothesis-python/src/hypothesis/core.py", line 1877, in wrapped_test
    arguments, kwargs, stuff = process_arguments_to_given(
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tybug/Desktop/Liam/coding/hypothesis/hypothesis-python/src/hypothesis/core.py", line 755, in process_arguments_to_given
    s.validate()
  File "/Users/tybug/Desktop/Liam/coding/hypothesis/hypothesis-python/src/hypothesis/strategies/_internal/strategies.py", line 482, in validate
    self.do_validate()
  File "/Users/tybug/Desktop/Liam/coding/hypothesis/hypothesis-python/src/hypothesis/strategies/_internal/lazy.py", line 161, in do_validate
    w.validate()
  File "/Users/tybug/Desktop/Liam/coding/hypothesis/hypothesis-python/src/hypothesis/strategies/_internal/strategies.py", line 484, in validate
    self.has_reusable_values
  File "/Users/tybug/Desktop/Liam/coding/hypothesis/hypothesis-python/src/hypothesis/strategies/_internal/strategies.py", line 266, in has_reusable_values
    return recursive_property(self, "has_reusable_values", True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tybug/Desktop/Liam/coding/hypothesis/hypothesis-python/src/hypothesis/strategies/_internal/strategies.py", line 216, in recursive_property
    return getattr(strategy, cache_key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'IntegersStrategy' object has no attribute 'cached_has_reusable_values'. Did you mean: 'calc_has_reusable_values'?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsomething is clearly wrong here

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions