Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: flexible inheritance segfault #24358

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

Merged
merged 1 commit into from
Aug 8, 2023

Conversation

tylerjereddy
Copy link
Contributor

@tylerjereddy
Copy link
Contributor Author

Looks like PyPy may deviate from CPython handling of tp_flags, not sure how much we should worry about that vs. ignoring PyPy on the test.

@mattip
Copy link
Member

mattip commented Aug 7, 2023

It seems indeed that test should be skipped on PyPy.There is a 5 year old issue about this problem

* Fixes numpy#23737

* based on the discussion in the issue above, this
completely blocks subclassing `np.flexible` at the Python
level and adds a test to ensure the segfault codepath
is no longer accessible
@@ -4122,7 +4122,7 @@ initialize_numeric_types(void)

/**begin repeat
* #NAME= Number, Integer, SignedInteger, UnsignedInteger, Inexact,
* Floating, ComplexFloating, Flexible, Character#
* Floating, ComplexFloating, Character#
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seberg none of these others are abstract base classes?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are, but I suspect flexible is the only one implementing things that cannot be inherited. Maybe that is the bigger problem really, but I guess this is also OK.

@mattip mattip merged commit 18f5287 into numpy:main Aug 8, 2023
@mattip
Copy link
Member

mattip commented Aug 8, 2023

Thanks @tylerjereddy

@tylerjereddy tylerjereddy deleted the treddy_issue_23737 branch August 8, 2023 15:36
@mattip
Copy link
Member

mattip commented Aug 13, 2023

This is causing problems after I fixed the PyPy flag handling, since CharacterArrType inherits from flexible here

SINGLE_INHERIT(Character, Flexible);

Why does CPython allow that?

@seberg
Copy link
Member

seberg commented Aug 13, 2023

CPython doesn't check this at all for C types I think.

@mattip
Copy link
Member

mattip commented Aug 13, 2023

Wow, that is weird. But OK, I think I can make PyPy mimic that behaviour. Disallowing inheritance for numpy.flexible doesn't seem right, it is meant to be a base class. Is this really the best solution for the problem being solved here?

@seberg
Copy link
Member

seberg commented Aug 13, 2023

Yah, sorry, I don't really feel this is terrible, but instead let's just delete code and burn down gentype_arrtype_getbuffer and gentype_arrtype_as_buffer completely: it doesn't make even remotely sense IMO and if anyone uses it they should just override it anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Stack overflow on double inheritance from numpy.flexible and numpy.ma.core.MaskedArray
3 participants