Skip to content

Conversation

WarrenWeckesser
Copy link
Member

Closes gh-166.

@WarrenWeckesser WarrenWeckesser force-pushed the quaddtype-fix-resolve-descriptors branch from 6d3cce2 to 92e2fa7 Compare October 8, 2025 19:40
@WarrenWeckesser WarrenWeckesser changed the title BUG: quaddtype: Don't reference pointer before knowing it is not NULL. BUG: quaddtype: Don't dereference pointer before knowing it is not NULL. Oct 8, 2025
@WarrenWeckesser
Copy link
Member Author

Is there a test I can add that would result in given_descrs[1] being NULL?

@seberg
Copy link
Member

seberg commented Oct 8, 2025

You could try quaddtype_arr.astype(QuadDType) (the class), but since that is already the same dtype... it probably doesn't trigger it and it is impossible.
To be honest, I am not even sure if this is easy to trigger for any non-paramtric dtype at all (although I suspect there are paths).

Either way, I would say its hard and maybe impossible. It's long enough ago that I wrote that code that I am not 100%, but...

@WarrenWeckesser
Copy link
Member Author

You could try quaddtype_arr.astype(QuadDType) (the class), but since that is already the same dtype... it probably doesn't trigger it ...

You're right, it doesn't result in given_descrs[1] being NULL.

@SwayamInSync
Copy link
Member

Thanks @WarrenWeckesser the patch make sense, but I'm not sure either when it can be NULL. I tried even passing None but it seems a default resolve descr runs in such cases.
Nvm merging this.

@SwayamInSync SwayamInSync merged commit d5b143f into numpy:main Oct 9, 2025
9 checks passed
@WarrenWeckesser WarrenWeckesser deleted the quaddtype-fix-resolve-descriptors branch October 9, 2025 12:32
@seberg
Copy link
Member

seberg commented Oct 9, 2025

I had a random thought just now that if you make the original array a structured dtype that contains the QuadDType and then cast it to QuadDType that may bypass some fast logic and go deeper.
But I don't think it's worth pursuing, just a bit of trivia :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

quaddtype: potential dereferencing bug in casts.cpp

3 participants