Skip to content
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

BUG: Fix comparator function signatures #20845

Merged
merged 1 commit into from Jan 17, 2022

Conversation

charris
Copy link
Member

@charris charris commented Jan 17, 2022

Backport of #20833.

The comparator functions are expected to have signature int f(void *, void*, PyArrayObject *).
Some of the comparators drop the third argument because they don't use them. Because the
comparators are unused, with most architectures this works fine. However, calling a function
pointer that has been cast to have a different number of arguments is undefined in the C
specification. With web assembly targets, it crashes at runtime.

This fixes the comparators defined in arraytypes.c.src to all take three arguments.

See also related work:
258ce25
23c05e6

The comparator functions are expected to have signature int f(void *, void*, PyArrayObject *).
Some of the comparators drop the third argument because they don't use them. Because the
comparators are unused, with most architectures this works fine. However, calling a function
pointer that has been cast to have a different number of arguments is undefined in the C
specification. With web assembly targets, it crashes at runtime.

This fixes the comparators defined in arraytypes.c.src to all take three arguments.

See also related work:
258ce25
23c05e6
@charris charris added 00 - Bug 08 - Backport Used to tag backport PRs labels Jan 17, 2022
@charris charris added this to the 1.22.2 release milestone Jan 17, 2022
@charris charris merged commit 9f31c32 into numpy:maintenance/1.22.x Jan 17, 2022
@charris charris deleted the backport-20833 branch January 17, 2022 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
00 - Bug 08 - Backport Used to tag backport PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants