Skip to content

BUG: avoid segfault on bad arguments in ndarray.__array_function__ - #27503

Merged
seberg merged 1 commit into
numpy:mainfrom
mhvk:ndarray_array_function_args_kwargs_check
Oct 4, 2024
Merged

seberg merged 1 commit into
numpy:mainfrom
mhvk:ndarray_array_function_args_kwargs_check

Conversation

@mhvk

@mhvk mhvk commented Oct 4, 2024

Copy link
Copy Markdown
Contributor

While looking into fixing #27500, I found that one can quite easily cause a core dump:

a = np.arange(3)
a.__array_function__(np.reshape, (np.ndarray,), a, (3, 1))
Segmentation fault (core dumped)

This is because the arguments to __array_function__ were not checked.

Now they are!

@seberg

seberg commented Oct 4, 2024

Copy link
Copy Markdown
Member

Thanks, Marten! (Not a huge deal, since nobody should call this directly and we sanitize it, but still good to check.)

@mhvk

mhvk commented Oct 4, 2024

Copy link
Copy Markdown
Contributor Author

Thanks. Agreed it is hard to hit, but people writing subclasses should still not get segfaults if they do the call wrong. And it is a cheap check. Anyway, happy it is in!

@mhvk
mhvk deleted the ndarray_array_function_args_kwargs_check branch October 4, 2024 18:49
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants