This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author JunyiXie
Recipients JunyiXie, vstinner
Date 2021-03-19.07:06:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1616137596.99.0.963932745487.issue43551@roundup.psfhosted.org>
In-reply-to
Content
fix PyImport_Import use static silly_list under building Python with --with-experimental-isolated-subinterpreters share silly_list in multi subinterpreters  cause crash.

Under the sub interpreters parallel, PyObject_CallFunction clean stack, 
Py_DECREF(stack[i]), Py_DECREF silly_list is not thread safe. cause crash
```
PyObject *
PyImport_Import(PyObject *module_name)
{
    PyThreadState *tstate = _PyThreadState_GET();
    static PyObject *silly_list = NULL;
    ...
    /* Initialize constant string objects */
    if (silly_list == NULL) {
        import_str = PyUnicode_InternFromString("__import__");
        if (import_str == NULL)
            return NULL;
        builtins_str = PyUnicode_InternFromString("__builtins__");
        if (builtins_str == NULL)
            return NULL;
        silly_list = PyList_New(0);
        if (silly_list == NULL)
            return NULL;
    }
    ...
    /* Call the __import__ function with the proper argument list
       Always use absolute import here.
       Calling for side-effect of import. */
    r = PyObject_CallFunction(import, "OOOOi", module_name, globals,
                              globals, silly_list, 0, NULL);

```
History
Date User Action Args
2021-03-19 07:06:37JunyiXiesetrecipients: + JunyiXie, vstinner
2021-03-19 07:06:36JunyiXiesetmessageid: <1616137596.99.0.963932745487.issue43551@roundup.psfhosted.org>
2021-03-19 07:06:36JunyiXielinkissue43551 messages
2021-03-19 07:06:36JunyiXiecreate