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
LSQBivariateSpline segmentation fault when quitting the Python terminal #13356
Comments
I have been having memory errors with A fairly reliable way to trigger this problem is to call the instantiation of I've set up a loop that repeatedly call the script, and beside simply Aborted or Segmentation Fault, occasionally I manage to get a Python traceback like this:
The test script was identical to the OP's except for larger input-array sizes and the duplicate calls to import numpy as np
from scipy.interpolate import LSQBivariateSpline
# generate data
x, y = np.meshgrid(
np.linspace(0, 10, 100),
np.linspace(0, 5, 100)
)
x = x.flatten()
y = y.flatten()
z = np.exp(-(x-5)**2/4) + np.exp(-(y-2)**2/3)
# define the knot positions
tx = np.linspace(0.1, 9.9, 32)
ty = np.linspace(0.1, 4.9, 33)
# get spline fit
s = LSQBivariateSpline(x, y, z, tx, ty, kx=3, ky=3)
s = LSQBivariateSpline(x, y, z, tx, ty, kx=3, ky=3)
s = LSQBivariateSpline(x, y, z, tx, ty, kx=3, ky=3)
# new evaluation
x2, y2 = np.meshgrid(
np.linspace(0, 10, 100),
np.linspace(0, 5, 100)
)
z_new = s(x2, y2, grid=False) |
In scipy.interpolate.LSQBivariateSpline, which calls the Fortran subroutine surfit as dfitpack.surfit_lsq via F2PY, pad both of the knot arrays to the size demanded by the Fortran routine. This fixes the memory error when the sizes of the input knot arrays are different. Note: The call signature to dfitpack.surfit_lsq is changed as a result of this fix. The input parameters nx and ny are no longer optional. Fixes scipygh-13356.
@CongliWANG If you can build scipy, could you please test your script against a build with the patch #13394? I think what happened was that the array allocated for one of the knot-location arrays was too small and causing out-of-bound access. This could happen, for example, when the spline degrees along x and y are the same but the numbers of knots differ. |
Hi @congma , Thank you for the fix. I checked out #13394 and built scipy with
But there is a missing library when I run the test script:
I believe the installation was not complete. May you advise on how to fix this? Thanks. |
@CongliWANG that's hard to say without a complete build log. Note that If you're doing it just to verify the fix: I can confirm that the segfaults are gone with gh-13394. |
In scipy.interpolate.LSQBivariateSpline, which calls the Fortran subroutine surfit as dfitpack.surfit_lsq via F2PY, pad both of the knot arrays to the size demanded by the Fortran routine. This fixes the memory error when the sizes of the input knot arrays are different. Note: The call signature to dfitpack.surfit_lsq is changed as a result of this fix. The input parameters nx and ny are no longer optional. Fixes scipygh-13356.
In scipy.interpolate.LSQBivariateSpline, which calls the Fortran subroutine surfit as dfitpack.surfit_lsq via F2PY, pad both of the knot arrays to the size demanded by the Fortran routine. This fixes the memory error when the sizes of the input knot arrays are different. Note: The call signature to dfitpack.surfit_lsq is changed as a result of this fix. The input parameters nx and ny are no longer optional. Fixes scipygh-13356.
This is not really bugging me, but just would like to know if there is anything wrong with the code (I am on Ubuntu 18.04 if that helps).
Reproducing code example (
test.py
):Error message:
Run code in terminal as
python -i test.py
, with the following error bumps out before quitting Python terminal:or
This error message shows up randomly, roughly 1 out of 5 trials will trigger the error.
Scipy/Numpy/Python version information:
The text was updated successfully, but these errors were encountered: