Skip to content

BUG: Fix missing check for PyErr_Occurred() in _pyarray_correlate. #28898

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

Merged
merged 1 commit into from
May 6, 2025

Conversation

hawkinsp
Copy link
Contributor

@hawkinsp hawkinsp commented May 4, 2025

When running the scipy 1.15 test suite test
signal/tests/test_signaltools.py::test_lfilter_bad_object, with Python built in debug mode, we see the following error:

Fatal Python error: _Py_CheckSlotResult: Slot * of type float succeeded with an exception set

None ends up as the first argument to dot, and this triggers an error from PyFloat_Multiply. Once an error has occurred, we must avoid calling multiply again, since it asserts that PyErr_Occurred() is false if the output is a non-error, which will fail if an error was set at entry.

When running the scipy 1.15 test suite test
signal/tests/test_signaltools.py::test_lfilter_bad_object, with Python
built in debug mode, we see the following error:

```
Fatal Python error: _Py_CheckSlotResult: Slot * of type float succeeded with an exception set
```

`None` ends up as the first argument to `dot`, and this triggers an
error from PyFloat_Multiply. Once an error has occurred, we must avoid
calling multiply again, since it asserts that PyErr_Occurred() is false
if the output is a non-error, which will fail if an error was set at
entry.
Copy link
Member

@seberg seberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose we used to get away a bit better with just continuing on error. Thanks, looks good to me, mid-term, the dot function should just return an error.

I think it would actually be OK to add a get_dotfunc function to the DType, and just stop using this implementation (maybe set the slot to NULL, or just keep it around a bit longer).

Would be nice to add a short test, although not sure if it is tedious to cover all paths here.

@charris charris added the 09 - Backport-Candidate PRs tagged should be backported label May 5, 2025
@ngoldbaum
Copy link
Member

Thanks @hawkinsp.

@ngoldbaum ngoldbaum merged commit de784cd into numpy:main May 6, 2025
73 of 74 checks passed
charris pushed a commit to charris/numpy that referenced this pull request May 6, 2025
…umpy#28898)

When running the scipy 1.15 test suite test
signal/tests/test_signaltools.py::test_lfilter_bad_object, with Python
built in debug mode, we see the following error:

```
Fatal Python error: _Py_CheckSlotResult: Slot * of type float succeeded with an exception set
```

`None` ends up as the first argument to `dot`, and this triggers an
error from PyFloat_Multiply. Once an error has occurred, we must avoid
calling multiply again, since it asserts that PyErr_Occurred() is false
if the output is a non-error, which will fail if an error was set at
entry.
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label May 6, 2025
MaanasArora pushed a commit to MaanasArora/numpy that referenced this pull request May 8, 2025
…umpy#28898)

When running the scipy 1.15 test suite test
signal/tests/test_signaltools.py::test_lfilter_bad_object, with Python
built in debug mode, we see the following error:

```
Fatal Python error: _Py_CheckSlotResult: Slot * of type float succeeded with an exception set
```

`None` ends up as the first argument to `dot`, and this triggers an
error from PyFloat_Multiply. Once an error has occurred, we must avoid
calling multiply again, since it asserts that PyErr_Occurred() is false
if the output is a non-error, which will fail if an error was set at
entry.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants