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
Type object's ob_type does not get set when tp_bases is set before PyType_Ready #104614
Labels
type-crash
A hard crash of the interpreter, possibly with a core dump
Comments
|
cc @ericsnowcurrently as the author of #103912. |
|
Verified that the following diff solves this issue, and the test suite passes. (Still not sure whether it has any unintended side-effects though) diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 2fbcafe91a..495e123f8f 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -6990,10 +6990,6 @@ type_ready_pre_checks(PyTypeObject *type)
static int
type_ready_set_bases(PyTypeObject *type)
{
- if (lookup_tp_bases(type) != NULL) {
- return 0;
- }
-
/* Initialize tp_base (defaults to BaseObject unless that's us) */
PyTypeObject *base = type->tp_base;
if (base == NULL && type != &PyBaseObject_Type) { |
|
I should have a fix up shortly. |
|
@lysnikolaou, please verify that gh-105122 fixes the problem. If not, what would be a good way to reproduce the problem? |
ericsnowcurrently
added a commit
that referenced
this issue
Jun 1, 2023
gh-105122) When I added the relevant condition to type_ready_set_bases() in gh-103912, I had missed that the function also sets tp_base and ob_type (if necessary). That led to problems for third-party static types. We fix that here, by making those extra operations distinct and by adjusting the condition to be more specific.
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Jun 1, 2023
…Ready() (pythongh-105122) When I added the relevant condition to type_ready_set_bases() in pythongh-103912, I had missed that the function also sets tp_base and ob_type (if necessary). That led to problems for third-party static types. We fix that here, by making those extra operations distinct and by adjusting the condition to be more specific. (cherry picked from commit 1469393) Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
ericsnowcurrently
pushed a commit
that referenced
this issue
Jun 1, 2023
…_Ready() (gh-105122) (gh-105211) When I added the relevant condition to type_ready_set_bases() in gh-103912, I had missed that the function also sets tp_base and ob_type (if necessary). That led to problems for third-party static types. We fix that here, by making those extra operations distinct and by adjusting the condition to be more specific. (cherry picked from commit 1469393) Co-authored-by: Eric Snow ericsnowcurrently@gmail.com
|
main and 3.12 should be good now. |
erlend-aasland
added a commit
to erlend-aasland/cpython
that referenced
this issue
Jun 2, 2023
erlend-aasland
added a commit
that referenced
this issue
Jun 2, 2023
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Jun 2, 2023
…_static_type() (pythonGH-105225) (cherry picked from commit e01b04c) Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
erlend-aasland
added a commit
that referenced
this issue
Jun 2, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug report
This came up while testing numpy on 3.12. A bug report has been filed on numpy/numpy#23766. It's happening due to #103912, which introduced an additional check for
tp_basesnot being NULL intype_ready_set_bases, which is called fromPyType_Ready.numpy sets
tp_basesmanually before callingPyType_Ready, which means that the afore-mentioned check succeeds, and so, the line that setsob_typedoes not get executed (it used to before #103912), which leads to a segmentation fault later on, when trying to setmro.This looks like a bug, but I'm not sure whether that's expected and numpy should be adjusted. If the latter is true, should a note be added in the
What's newdocument?Linked PRs
The text was updated successfully, but these errors were encountered: