Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Test test_run_in_process_multiple_threads_sequential fails #4416

Open
3 tasks done
yurivict opened this issue Dec 23, 2022 · 0 comments
Open
3 tasks done

[BUG]: Test test_run_in_process_multiple_threads_sequential fails #4416

yurivict opened this issue Dec 23, 2022 · 0 comments
Labels
triage New bug, unverified

Comments

@yurivict
Copy link

Required prerequisites

What version (or hash if on master) of pybind11 are you using?

2.10.2

Problem description

__________________________________________________ test_run_in_process_multiple_threads_sequential[test_multi_acquire_release_cross_module] __________________________________________________

test_fn = <function test_multi_acquire_release_cross_module at 0x8cbf75280>

    @pytest.mark.parametrize("test_fn", ALL_BASIC_TESTS_PLUS_INTENTIONAL_DEADLOCK)
    def test_run_in_process_multiple_threads_sequential(test_fn):
        """Makes sure there is no GIL deadlock when running in a thread multiple times sequentially.
    
        It runs in a separate process to be able to stop and assert if it deadlocks.
        """
>       assert _run_in_process(_run_in_threads, test_fn, num_threads=8, parallel=False) == 0

test_fn    = <function test_multi_acquire_release_cross_module at 0x8cbf75280>

../../pybind11-2.10.2/tests/test_gil_scoped.py:234: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

target = <function _run_in_threads at 0x8cbf754c0>, args = (<function test_multi_acquire_release_cross_module at 0x8cbf75280>,), kwargs = {'num_threads': 8, 'parallel': False}
test_fn = <function test_multi_acquire_release_cross_module at 0x8cbf75280>, timeout = 10, process = <Process name='Process-53' pid=32667 parent=30786 stopped exitcode=-SIGTERM daemon>
t_start = 1671766594.3010159, t_delta = 10.004453420639038, @py_assert1 = None

    def _run_in_process(target, *args, **kwargs):
        if len(args) == 0:
            test_fn = target
        else:
            test_fn = args[0]
        # Do not need to wait much, 10s should be more than enough.
        timeout = 0.1 if test_fn is _intentional_deadlock else 10
        process = multiprocessing.Process(target=target, args=args, kwargs=kwargs)
        process.daemon = True
        try:
            t_start = time.time()
            process.start()
            if timeout >= 100:  # For debugging.
                print(
                    "\nprocess.pid STARTED", process.pid, (sys.argv, target, args, kwargs)
                )
                print(f"COPY-PASTE-THIS: gdb {sys.argv[0]} -p {process.pid}", flush=True)
            process.join(timeout=timeout)
            if timeout >= 100:
                print("\nprocess.pid JOINED", process.pid, flush=True)
            t_delta = time.time() - t_start
            if process.exitcode == 66 and m.defined_THREAD_SANITIZER:  # Issue #2754
                # WOULD-BE-NICE-TO-HAVE: Check that the message below is actually in the output.
                # Maybe this could work:
                # https://gist.github.com/alexeygrigorev/01ce847f2e721b513b42ea4a6c96905e
                pytest.skip(
                    "ThreadSanitizer: starting new threads after multi-threaded fork is not supported."
                )
            elif test_fn is _intentional_deadlock:
                assert process.exitcode is None
                return 0
            elif process.exitcode is None:
                assert t_delta > 0.9 * timeout
                msg = "DEADLOCK, most likely, exactly what this test is meant to detect."
                if env.PYPY and env.WIN:
                    pytest.skip(msg)
>               raise RuntimeError(msg)
E               RuntimeError: DEADLOCK, most likely, exactly what this test is meant to detect.

args       = (<function test_multi_acquire_release_cross_module at 0x8cbf75280>,)
kwargs     = {'num_threads': 8, 'parallel': False}
msg        = 'DEADLOCK, most likely, exactly what this test is meant to detect.'
process    = <Process name='Process-53' pid=32667 parent=30786 stopped exitcode=-SIGTERM daemon>
t_delta    = 10.004453420639038
t_start    = 1671766594.3010159
target     = <function _run_in_threads at 0x8cbf754c0>
test_fn    = <function test_multi_acquire_release_cross_module at 0x8cbf75280>
timeout    = 10

../../pybind11-2.10.2/tests/test_gil_scoped.py:186: RuntimeError
================================================================================== short test summary info ===================================================================================
SKIPPED [1] ../../pybind11-2.10.2/tests/test_builtin_casters.py:145: no <string_view>
SKIPPED [1] ../../pybind11-2.10.2/tests/test_callbacks.py:203: Current PYBIND11_INTERNALS_VERSION too low
SKIPPED [1] ../../pybind11-2.10.2/tests/test_copy_move.py:77: no <optional>
SKIPPED [1] ../../pybind11-2.10.2/tests/test_pytypes.py:397: Not defined: PYBIND11_HANDLE_REF_DEBUG
SKIPPED [1] ../../pybind11-2.10.2/tests/test_sequences_and_iterators.py:13: no <optional>
SKIPPED [1] ../../pybind11-2.10.2/tests/test_stl.py:111: no <optional>
SKIPPED [1] ../../pybind11-2.10.2/tests/test_stl.py:143: no <experimental/optional>
SKIPPED [1] ../../pybind11-2.10.2/tests/test_stl.py:234: no <filesystem>
SKIPPED [1] ../../pybind11-2.10.2/tests/test_stl.py:270: no std::monostate
FAILED ../../pybind11-2.10.2/tests/test_exceptions.py::test_cross_module_exception_translator - RuntimeError
FAILED ../../pybind11-2.10.2/tests/test_gil_scoped.py::test_run_in_process_multiple_threads_sequential[test_multi_acquire_release_cross_module] - RuntimeError: DEADLOCK, most likely, exactly what this test is meant to detect.
==================================================================== 2 failed, 780 passed, 9 skipped in 151.14s (0:02:31) ====================================================================

Reproducible example code

No response

Is this a regression? Put the last known working version here if it is.

Not a regression

@yurivict yurivict added the triage New bug, unverified label Dec 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage New bug, unverified
Projects
None yet
Development

No branches or pull requests

1 participant