Skip to content

BUG: Fix comparator function signatures#20845

Merged
charris merged 1 commit intonumpy:maintenance/1.22.xfrom
charris:backport-20833
Jan 17, 2022
Merged

BUG: Fix comparator function signatures#20845
charris merged 1 commit intonumpy:maintenance/1.22.xfrom
charris:backport-20833

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.

2 participants