Skip to content

Subprocess crashes in test_download_parallel_from_internet_works #9699

@dhomeier

Description

@dhomeier

Description

On Python 3.6-3.7 (at least) one of the processes spawned in the above test segfaults.

Actual behavior

../../sw/lib/python3.7/site-packages/astropy/utils/tests/test_data.py::test_download_parallel_from_internet_works Fatal Python error: Segmentation fault

Current thread 0x00007fffa857e3c0 (most recent call first):
  File "/sw/lib/python3.7/socket.py", line 748 in getaddrinfo
  File "/sw/lib/python3.7/socket.py", line 707 in create_connection
  File "/sw/lib/python3.7/http/client.py", line 938 in connect
  File "/sw/lib/python3.7/http/client.py", line 966 in send
  File "/sw/lib/python3.7/http/client.py", line 1026 in _send_output
  File "/sw/lib/python3.7/http/client.py", line 1247 in endheaders
  File "/sw/lib/python3.7/http/client.py", line 1298 in _send_request
  File "/sw/lib/python3.7/http/client.py", line 1252 in request
  File "/sw/lib/python3.7/urllib/request.py", line 1317 in do_open
  File "/sw/lib/python3.7/urllib/request.py", line 1345 in http_open
  File "/sw/lib/python3.7/urllib/request.py", line 503 in _call_chain
  File "/sw/lib/python3.7/urllib/request.py", line 543 in _open
  File "/sw/lib/python3.7/urllib/request.py", line 525 in open
  File "/sw/lib/python3.7/urllib/request.py", line 222 in urlopen
  File "/sw/lib/python3.7/site-packages/astropy/utils/data.py", line 979 in _download_file_from_source
  File "/sw/lib/python3.7/site-packages/astropy/utils/data.py", line 1147 in download_file
  File "/sw/lib/python3.7/site-packages/astropy/utils/data.py", line 1243 in _do_download_files_in_parallel
  File "/sw/lib/python3.7/site-packages/astropy/utils/console.py", line 499 in __call__
  File "/sw/lib/python3.7/concurrent/futures/process.py", line 239 in _process_worker
  File "/sw/lib/python3.7/multiprocessing/process.py", line 99 in run
  File "/sw/lib/python3.7/multiprocessing/process.py", line 297 in _bootstrap
  File "/sw/lib/python3.7/multiprocessing/popen_fork.py", line 74 in _launch
  File "/sw/lib/python3.7/multiprocessing/popen_fork.py", line 20 in __init__
  File "/sw/lib/python3.7/multiprocessing/context.py", line 277 in _Popen
  File "/sw/lib/python3.7/multiprocessing/process.py", line 112 in start
  File "/sw/lib/python3.7/concurrent/futures/process.py", line 607 in _adjust_process_count
  File "/sw/lib/python3.7/concurrent/futures/process.py", line 583 in _start_queue_management_thread
  File "/sw/lib/python3.7/concurrent/futures/process.py", line 641 in submit
  File "/sw/lib/python3.7/site-packages/astropy/utils/console.py", line 850 in <genexpr>
  File "/sw/lib/python3.7/concurrent/futures/_base.py", line 217 in as_completed
  File "/sw/lib/python3.7/site-packages/astropy/utils/console.py", line 850 in map_unordered
  File "/sw/lib/python3.7/site-packages/astropy/utils/console.py", line 756 in map
  File "/sw/lib/python3.7/site-packages/astropy/utils/data.py", line 1362 in download_files_in_parallel
  File "/sw/lib/python3.7/site-packages/astropy/utils/tests/test_data.py", line 525 in test_download_parallel_from_internet_works
  File "/sw/lib/python3.7/site-packages/_pytest/python.py", line 176 in pytest_pyfunc_call
  File "/sw/lib/python3.7/site-packages/pluggy/callers.py", line 187 in _multicall
  File "/sw/lib/python3.7/site-packages/pluggy/manager.py", line 86 in <lambda>
  File "/sw/lib/python3.7/site-packages/pluggy/manager.py", line 92 in _hookexec
  File "/sw/lib/python3.7/site-packages/pluggy/hooks.py", line 286 in __call__
  File "/sw/lib/python3.7/site-packages/_pytest/python.py", line 1445 in runtest
  File "/sw/lib/python3.7/site-packages/_pytest/runner.py", line 126 in pytest_runtest_call
  File "/sw/lib/python3.7/site-packages/pluggy/callers.py", line 187 in _multicall
  File "/sw/lib/python3.7/site-packages/pluggy/manager.py", line 86 in <lambda>
  File "/sw/lib/python3.7/site-packages/pluggy/manager.py", line 92 in _hookexec
  File "/sw/lib/python3.7/site-packages/pluggy/hooks.py", line 286 in __call__
  File "/sw/lib/python3.7/site-packages/flaky/flaky_pytest_plugin.py", line 306 in <lambda>
  File "/sw/lib/python3.7/site-packages/_pytest/runner.py", line 229 in from_call
  File "/sw/lib/python3.7/site-packages/flaky/flaky_pytest_plugin.py", line 307 in call_runtest_hook
  File "/sw/lib/python3.7/site-packages/flaky/flaky_pytest_plugin.py", line 129 in call_and_report
  File "/sw/lib/python3.7/site-packages/_pytest/runner.py", line 96 in runtestprotocol
  File "/sw/lib/python3.7/site-packages/_pytest/runner.py", line 81 in pytest_runtest_protocol
  File "/sw/lib/python3.7/site-packages/flaky/flaky_pytest_plugin.py", line 92 in pytest_runtest_protocol
  File "/sw/lib/python3.7/site-packages/pluggy/callers.py", line 187 in _multicall
  File "/sw/lib/python3.7/site-packages/pluggy/manager.py", line 86 in <lambda>
  File "/sw/lib/python3.7/site-packages/pluggy/manager.py", line 92 in _hookexec
  File "/sw/lib/python3.7/site-packages/pluggy/hooks.py", line 286 in __call__
  File "/sw/lib/python3.7/site-packages/_pytest/main.py", line 264 in pytest_runtestloop
  File "/sw/lib/python3.7/site-packages/pluggy/callers.py", line 187 in _multicall
  File "/sw/lib/python3.7/site-packages/pluggy/manager.py", line 86 in <lambda>
  File "/sw/lib/python3.7/site-packages/pluggy/manager.py", line 92 in _hookexec
  File "/sw/lib/python3.7/site-packages/pluggy/hooks.py", line 286 in __call__
  File "/sw/lib/python3.7/site-packages/_pytest/main.py", line 240 in _main
  File "/sw/lib/python3.7/site-packages/_pytest/main.py", line 196 in wrap_session
  File "/sw/lib/python3.7/site-packages/_pytest/main.py", line 233 in pytest_cmdline_main
  File "/sw/lib/python3.7/site-packages/pluggy/callers.py", line 187 in _multicall
  File "/sw/lib/python3.7/site-packages/pluggy/manager.py", line 86 in <lambda>
  File "/sw/lib/python3.7/site-packages/pluggy/manager.py", line 92 in _hookexec
  File "/sw/lib/python3.7/site-packages/pluggy/hooks.py", line 286 in __call__
  File "/sw/lib/python3.7/site-packages/_pytest/config/__init__.py", line 92 in main
  File "/sw/lib/python3.7/site-packages/astropy/tests/runner.py", line 248 in run_tests
  File "/sw/lib/python3.7/site-packages/astropy/tests/runner.py", line 611 in run_tests
  File "/sw/lib/python3.7/site-packages/astropy/tests/runner.py", line 266 in test
  File "<string>", line 1 in <module>
FAILED                      [ 34%]
____________________________________________________ test_download_parallel_from_internet_works _____________________________________________________

temp_cache = None

    @pytest.mark.remote_data(source="astropy")
    def test_download_parallel_from_internet_works(temp_cache):
        main_url = conf.dataurl
        mirror_url = conf.dataurl_mirror
        fileloc = "intersphinx/README"
        urls = []
        sources = {}
        for s in ["", fileloc]:
            urls.append(main_url + s)
            sources[urls[-1]] = [urls[-1], mirror_url+s]
>       fnout = download_files_in_parallel(urls, sources=sources)

/sw/lib/python3.7/site-packages/astropy/utils/tests/test_data.py:525: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/sw/lib/python3.7/site-packages/astropy/utils/data.py:1362: in download_files_in_parallel
    multiprocessing_start_method=multiprocessing_start_method,
/sw/lib/python3.7/site-packages/astropy/utils/console.py:756: in map
    multiprocessing_start_method=multiprocessing_start_method)
/sw/lib/python3.7/site-packages/astropy/utils/console.py:852: in map_unordered
    results.append(f.result())
/sw/lib/python3.7/concurrent/futures/_base.py:428: in result
    return self.__get_result()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <Future at 0x1184adb90 state=finished raised BrokenProcessPool>

    def __get_result(self):
        if self._exception:
>           raise self._exception
E           concurrent.futures.process.BrokenProcessPool: A process in the process pool was terminated abruptly while the future was running or pending.

/sw/lib/python3.7/concurrent/futures/_base.py:384: BrokenProcessPool

Steps to Reproduce

Apparently this only happens when (presumably) test_open_network_url from the suite of utils tests is previously run, i.e.

python -c 'import astropy; astropy.test(package="utils", args="-vk \" _open_network_url or _download\"", remote_data=True)'

does trigger the error, while

python -c 'import astropy; astropy.test(package="utils", args="-vk _download", remote_data=True)'

on its own does not.
Arguably this has improved compared to 3.2.3, where the main Python process would become locked up as well.
Everything succeeds on Python 3.8.0

System Details

platform darwin -- Python 3.7.5, pytest-5.3.0, py-1.8.0, pluggy-0.13.0 -- /sw/bin/python3.7
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/Users/derek/.hypothesis/examples')

Running tests with Astropy version 4.0rc1.
Running tests in astropy/utils.

Date: 2019-11-27T21:11:09

Platform: Darwin-16.7.0-x86_64-i386-64bit

Executable: /sw/bin/python3.7

Full Python Version: 
3.7.5 (default, Nov  2 2019, 21:26:51) 
[Clang 9.0.0 (clang-900.0.39.2)]

encodings: sys: utf-8, locale: UTF-8, filesystem: utf-8
byteorder: little
float info: dig: 15, mant_dig: 15

Package versions: 
Numpy: 1.17.4
Scipy: 1.3.2
Matplotlib: 3.1.0
h5py: 2.9.0
Pandas: 0.25.3
Cython: 0.29.13
Scikit-image: not available
asdf: 2.4.2
astropy-helpers: 4.0.rc1

Using Astropy options: remote_data: any.

Matplotlib: 3.1.0
Freetype: 2.6.1
rootdir: /sw/lib/python3.7/site-packages
plugins: asdf-2.4.2, flaky-3.5.3, hypothesis-4.36.0, arraydiff-0.3, astropy-header-0.1.1, cov-2.6.0, doctestplus-0.5.0, flake8-1.0.4, forked-1.1.3, mock-1.10.4, mpl-0.11, openfiles-0.3.2, remotedata-0.3.1
collected 301 items / 240 deselected / 61 selected

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions