scipy: BUG: median_filter on 1D array crashes with memory corruption using SciPy 1.15.0
Describe your issue.
When I run median_filter on a 1D array, Python crashes. The crash occurs in SciPy 1.15.0. It runs fine in SciPy 1.14.1.
Reproducing Code Example
import numpy as np
from scipy.ndimage import median_filter
# Create a demo image
np.random.seed(42) # For reproducibility
image = np.zeros((9044, ))
# Add random noise
noisy_image = image + 0.4 * np.random.random(image.shape)
# Apply median filtering
filtered_image = median_filter(noisy_image, size=10, mode='wrap')
Error message
$ python3 median.py
corrupted size vs. prev_size
Aborted (core dumped)
SciPy/NumPy/Python version and system information
>>> import sys, scipy, numpy; print(scipy.__version__, numpy.__version__, sys.version_info); scipy.show_config()
1.15.0 1.26.4 sys.version_info(major=3, minor=12, micro=3, releaselevel='final', serial=0)
Build Dependencies:
blas:
detection method: pkgconfig
found: true
include directory: /opt/_internal/cpython-3.12.7/lib/python3.12/site-packages/scipy_openblas32/include
lib directory: /opt/_internal/cpython-3.12.7/lib/python3.12/site-packages/scipy_openblas32/lib
name: scipy-openblas
openblas configuration: OpenBLAS 0.3.28 DYNAMIC_ARCH NO_AFFINITY Haswell MAX_THREADS=64
pc file directory: /project
version: 0.3.28
lapack:
detection method: pkgconfig
found: true
include directory: /opt/_internal/cpython-3.12.7/lib/python3.12/site-packages/scipy_openblas32/include
lib directory: /opt/_internal/cpython-3.12.7/lib/python3.12/site-packages/scipy_openblas32/lib
name: scipy-openblas
openblas configuration: OpenBLAS 0.3.28 DYNAMIC_ARCH NO_AFFINITY Haswell MAX_THREADS=64
pc file directory: /project
version: 0.3.28
pybind11:
detection method: config-tool
include directory: unknown
name: pybind11
version: 2.13.6
Compilers:
c:
commands: cc
linker: ld.bfd
name: gcc
version: 10.2.1
c++:
commands: c++
linker: ld.bfd
name: gcc
version: 10.2.1
cython:
commands: cython
linker: cython
name: cython
version: 3.0.11
fortran:
commands: gfortran
linker: ld.bfd
name: gcc
version: 10.2.1
pythran:
include directory: ../../tmp/pip-build-env-4fhy_u4k/overlay/lib/python3.12/site-packages/pythran
version: 0.17.0
Machine Information:
build:
cpu: x86_64
endian: little
family: x86_64
system: linux
cross-compiled: false
host:
cpu: x86_64
endian: little
family: x86_64
system: linux
Python Information:
path: /opt/python/cp312-cp312/bin/python
version: '3.12'
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 16 (9 by maintainers)
Commits related to this issue
- WIP, BUG: wrap median_filter stability * Related to gh-22250 * The shims in this branch seem to substantially improve the probability of the new `test_gh_22250` to pass under high repeat counts with... — committed to tylerjereddy/scipy by tylerjereddy 2 years ago
- WIP, BUG: wrap median_filter stability * Related to gh-22250 * The shims in this branch seem to substantially improve the probability of the new `test_gh_22250` to pass under high repeat counts with... — committed to tylerjereddy/scipy by tylerjereddy 2 years ago
- WIP, TST: guard more `median_filter` crashes * Add new/thorough property-based test `test_gh_22250_crash_property()` to guard against additional `median_filter` crashes like the one reported at: http... — committed to tylerjereddy/scipy by tylerjereddy 2 years ago
I hope so. will try to do it soon
@PierreRaybaut I opened a new ticket above with a property-based test to reproduce, thanks for reporting.
Hi there,
I’m afraid that there is still an issue with
median_filterwhich would lead me to state that the bug was partially fixed. Same symptoms: code runs fine with SciPy 1.14.1 and crashes from SciPy 1.15.0 to 1.15.2 (latest release as of today).I’ve managed to reproduce the issue with a simple test with
size=15andmode='mirror':Result is the following:
Even if the
srcis an internal DataLab object, thexandyare simple 1D NumPy float arrays. The following is an extract from the GitHub Actions workflow CI log and give everything you need to reproduce the bug on your own: