[New-bugs-announce] [issue44532] multi subinterpreters use _PyStructSequence_InitType failed.

junyixie report at bugs.python.org
Tue Jun 29 02:53:42 EDT 2021


New submission from junyixie <xie.junyi at outlook.com>:

In _PyStructSequence_InitType, it will check type is initialized.
but when we have multi subinterpreters, type may be initialized expected.

when type already been initialized, should return 0 rather than throw exception.
```c
/* PyTypeObject has already been initialized */
if (Py_REFCNT(type) != 0) {
    return 0;
}
```


```c
int
_PyStructSequence_InitType(PyTypeObject *type, PyStructSequence_Desc *desc,
                           unsigned long tp_flags)
{
    PyMemberDef *members;
    Py_ssize_t n_members, n_unnamed_members;

#ifdef Py_TRACE_REFS
    /* if the type object was chained, unchain it first
       before overwriting its storage */
    if (type->ob_base.ob_base._ob_next) {
        _Py_ForgetReference((PyObject *)type);
    }
#endif

    /* PyTypeObject has already been initialized */
    if (Py_REFCNT(type) != 0) {
        PyErr_BadInternalCall();
        return -1;
    }
```

----------
components: Subinterpreters
messages: 396703
nosy: JunyiXie
priority: normal
severity: normal
status: open
title: multi subinterpreters use _PyStructSequence_InitType failed.
type: crash

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44532>
_______________________________________


More information about the New-bugs-announce mailing list