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: core: result_type(0, np.timedelta64(4)) would seg. fault. #20106

Merged
merged 1 commit into from Oct 12, 2021

Conversation

charris
Copy link
Member

@charris charris commented Oct 12, 2021

Backport of #20088.

Before this change, the line in convert_datatype.c

result = PyArray_CastDescrToDType(all_descriptors[0], common_dtype);

would trigger a seg. fault with a call such as

np.result_type(0, np.timedelta64(4))

The problem was that all_descriptors[0] was NULL, and it was
dereferenced in PyArray_CastDescrToDType.

The code in the loop that followed the above line avoided passing
NULL values in all_descriptors[i] to PyArray_CastDescrToDType by
checking that the corresponding input argument to result_type
was not a Python scalar. A different code path was taken in that
case. The seg. fault is fixed by applying that same check to the
first argument.

Closes gh-20077.

@charris charris added this to the 1.21.3 release milestone Oct 12, 2021
@charris charris merged commit c36c4e3 into numpy:maintenance/1.21.x Oct 12, 2021
@charris charris deleted the backport-20088 branch October 12, 2021 19:14
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.

None yet

1 participant