astrofrog / fast-histogram

:zap: Fast 1D and 2D histogram functions in Python :zap:

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[0.11] Segmentation fault on tests

olebole opened this issue · comments

Forwarding Debian#1026594:
Since a few weeks, the package produces a segmentation fault when running the tests:

autopkgtest [11:23:37]: test command1: cd $AUTOPKGTEST_TMP && python3 -m pytest --pyargs fast_histogram
autopkgtest [11:23:37]: test command1: [-----------------------
============================= test session starts ==============================
platform linux -- Python 3.11.1, pytest-7.2.0, pluggy-1.0.0+repack
rootdir: /tmp/autopkgtest-lxc.adqdcee1/downtmp/autopkgtest_tmp
plugins: hypothesis-6.61.0
collected 9 items

tests/test_histogram.py FFatal Python error: Segmentation fault

Current thread 0x00007f633c836040 (most recent call first):
  Garbage-collecting
  File "/usr/lib/python3/dist-packages/hypothesis/internal/conjecture/data.py", line 850 in __init__
  File "/usr/lib/python3/dist-packages/hypothesis/internal/conjecture/engine.py", line 891 in new_conjecture_data
  File "/usr/lib/python3/dist-packages/hypothesis/internal/conjecture/engine.py", line 1031 in cached_test_function
  File "/usr/lib/python3/dist-packages/hypothesis/internal/conjecture/engine.py", line 803 in generate_mutations_from
  File "/usr/lib/python3/dist-packages/hypothesis/internal/conjecture/engine.py", line 733 in generate_new_examples
  File "/usr/lib/python3/dist-packages/hypothesis/internal/conjecture/engine.py", line 880 in _run
  File "/usr/lib/python3/dist-packages/hypothesis/internal/conjecture/engine.py", line 474 in run
  File "/usr/lib/python3/dist-packages/hypothesis/core.py", line 884 in run_engine
  File "/usr/lib/python3/dist-packages/hypothesis/core.py", line 1292 in wrapped_test
  File "/usr/lib/python3/dist-packages/fast_histogram/tests/test_histogram.py", line 78 in test_2d_compare_with_numpy
  File "/usr/lib/python3/dist-packages/_pytest/python.py", line 195 in pytest_pyfunc_call
  File "/usr/lib/python3/dist-packages/pluggy/_callers.py", line 39 in _multicall
  File "/usr/lib/python3/dist-packages/pluggy/_manager.py", line 80 in _hookexec
  File "/usr/lib/python3/dist-packages/pluggy/_hooks.py", line 265 in __call__
  File "/usr/lib/python3/dist-packages/_pytest/python.py", line 1789 in runtest
  File "/usr/lib/python3/dist-packages/_pytest/runner.py", line 167 in pytest_runtest_call
  File "/usr/lib/python3/dist-packages/pluggy/_callers.py", line 39 in _multicall
  File "/usr/lib/python3/dist-packages/pluggy/_manager.py", line 80 in _hookexec
  File "/usr/lib/python3/dist-packages/pluggy/_hooks.py", line 265 in __call__
  File "/usr/lib/python3/dist-packages/_pytest/runner.py", line 260 in <lambda>
  File "/usr/lib/python3/dist-packages/_pytest/runner.py", line 339 in from_call
  File "/usr/lib/python3/dist-packages/_pytest/runner.py", line 259 in call_runtest_hook
  File "/usr/lib/python3/dist-packages/_pytest/runner.py", line 220 in call_and_report
  File "/usr/lib/python3/dist-packages/_pytest/runner.py", line 131 in runtestprotocol
  File "/usr/lib/python3/dist-packages/_pytest/runner.py", line 112 in pytest_runtest_protocol
  File "/usr/lib/python3/dist-packages/pluggy/_callers.py", line 39 in _multicall
  File "/usr/lib/python3/dist-packages/pluggy/_manager.py", line 80 in _hookexec
  File "/usr/lib/python3/dist-packages/pluggy/_hooks.py", line 265 in __call__
  File "/usr/lib/python3/dist-packages/_pytest/main.py", line 349 in pytest_runtestloop
  File "/usr/lib/python3/dist-packages/pluggy/_callers.py", line 39 in _multicall
  File "/usr/lib/python3/dist-packages/pluggy/_manager.py", line 80 in _hookexec
  File "/usr/lib/python3/dist-packages/pluggy/_hooks.py", line 265 in __call__
  File "/usr/lib/python3/dist-packages/_pytest/main.py", line 324 in _main
  File "/usr/lib/python3/dist-packages/_pytest/main.py", line 270 in wrap_session
  File "/usr/lib/python3/dist-packages/_pytest/main.py", line 317 in pytest_cmdline_main
  File "/usr/lib/python3/dist-packages/pluggy/_callers.py", line 39 in _multicall
  File "/usr/lib/python3/dist-packages/pluggy/_manager.py", line 80 in _hookexec
  File "/usr/lib/python3/dist-packages/pluggy/_hooks.py", line 265 in __call__
  File "/usr/lib/python3/dist-packages/_pytest/config/__init__.py", line 167 in main
  File "/usr/lib/python3/dist-packages/_pytest/config/__init__.py", line 190 in console_main
  File "/usr/lib/python3/dist-packages/pytest/__main__.py", line 5 in <module>
  File "<frozen runpy>", line 88 in _run_code
  File "<frozen runpy>", line 198 in _run_module_as_main

Extension modules: numpy.core._multiarray_umath, numpy.core._multiarray_tests, numpy.linalg._umath_linalg, numpy.fft._pocketfft_internal, numpy.random._common, numpy.random.bit_generator, numpy.random._bounded_integers, numpy.random._mt19937, numpy.random.mtrand, numpy.random._philox, numpy.random._pcg64, numpy.random._sfc64, numpy.random._generator, fast_histogram._histogram_core, numpy.linalg.lapack_lite (total: 15)
Segmentation fault

This happens with both Python3.10.9 and 3.11.1. Other versions:

  • hypothesis 6.60.0, 6.61.0 (6.36.0 works!)
  • numpy 1.23.5, 1.24.1
  • pytest 7.2.0,
  • pluggy 1.0.0

This happens both when running during the build (log) and when testing with python3 -m pytest --pyargs fast_histogram on the installed package (log).

Any idea here? This seems to be a regression with newer "hypothesis" versions; however hypothesis itself is a pure Python package and therefore should not cause a segfault.
fast-histogram is used by quite a few packages; I'd like to keep it (and the packages that depend on it) in Debian. Shall I just pragmatically disable the tests?

Will try and investigate shortly - I am guessing this is a new hypothesis test case that is segfaulting

Running into a similar issue in spacetelescope/jdaviz#2498 when using the histogram viewer from glue-jupyter. If this isn't directly related, feel free to split into a separate issue.

Current thread 0x00007f4c96c5ec40 (most recent call first):
  File "/home/runner/work/jdaviz/jdaviz/.tox/py311-test-alldeps-cov/lib/python3.11/site-packages/fast_histogram/histogram.py", line 58 in histogram1d
  File "/home/runner/work/jdaviz/jdaviz/.tox/py311-test-alldeps-cov/lib/python3.11/site-packages/glue/core/data.py", line 2021 in compute_histogram
  File "/home/runner/work/jdaviz/jdaviz/.tox/py311-test-alldeps-cov/lib/python3.11/site-packages/glue/viewers/histogram/state.py", line 254 in update_histogram
  File "/home/runner/work/jdaviz/jdaviz/.tox/py311-test-alldeps-cov/lib/python3.11/site-packages/glue/viewers/histogram/state.py", line 217 in histogram
  File "/home/runner/work/jdaviz/jdaviz/.tox/py311-test-alldeps-cov/lib/python3.11/site-packages/glue_jupyter/bqplot/histogram/layer_artist.py", line 51 in _calculate_histogram
  File "/home/runner/work/jdaviz/jdaviz/.tox/py311-test-alldeps-cov/lib/python3.11/site-packages/glue_jupyter/bqplot/histogram/layer_artist.py", line 142 in _update_histogram
  File "/home/runner/work/jdaviz/jdaviz/.tox/py311-test-alldeps-cov/lib/python3.11/site-packages/glue_jupyter/bqplot/histogram/layer_artist.py", line 153 in update
  ...

@kecnry would you be able to print out or save the arguments being passed to histogram1d that are causing the segfault?

It seems that it was caused (on our end) by passing arrays of length 1 to the histogram. We can just prevent passing these for now with a workaround, but it would be great if this could either be gracefully handled or raise an error instead of resulting in a segfault.