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.

classification
Title: [Subinterpreters]: use static variable under building Python with --with-experimental-isolated-subinterpreters cause crash.
Type: crash Stage: patch review
Components: Subinterpreters Versions: Python 3.10
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: JunyiXie, corona10, kumaraditya, shihai1991, vstinner
Priority: normal Keywords: patch

Created on 2021-03-22 08:09 by JunyiXie, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 24963 closed JunyiXie, 2021-03-22 08:18
PR 24929 JunyiXie, 2021-03-22 08:20
PR 24965 closed JunyiXie, 2021-03-22 10:15
PR 24966 closed JunyiXie, 2021-03-22 10:32
PR 24968 closed JunyiXie, 2021-03-22 13:05
PR 24969 closed JunyiXie, 2021-03-22 13:19
PR 24970 open JunyiXie, 2021-03-22 13:41
PR 24971 closed JunyiXie, 2021-03-22 20:31
PR 24972 closed JunyiXie, 2021-03-22 20:31
Messages (13)
msg389282 - (view) Author: junyixie (JunyiXie) * Date: 2021-03-22 08:09
use static module variable under building Python with --with-experimental-isolated-subinterpreters cause crash.
compiler_mod(struct compiler *c, mod_ty mod)
{
    PyCodeObject *co;
    int addNone = 1;
    static PyObject *module;
    if (!module) {
        module = PyUnicode_InternFromString("<module>");
        if (!module)
            return NULL;
    }
...
}
msg389284 - (view) Author: junyixie (JunyiXie) * Date: 2021-03-22 08:20
43551 [Subinterpreters]: PyImport_Import use static silly_list under building Python with --with-experimental-isolated-subinterpreters share silly_list in multi subinterpreters  cause crash.
https://bugs.python.org/issue43551
msg389292 - (view) Author: junyixie (JunyiXie) * Date: 2021-03-22 09:58
grep -E 'static (\w+) \*(\w+) =' $(find . -name "*.c") | wc -l
67 static variable may need fix
➜  cpython git:(master) grep -E 'static (\w+) \*(\w+) =' $(find . -name "*.c")
./PC/winreg.c:static char *failMsg = "bad operand type";
./Python/codecs.c:static _PyUnicode_Name_CAPI *ucnhash_capi = NULL;
./Python/initconfig.c:static char *_Py_StandardStreamEncoding = NULL;
./Python/initconfig.c:static char *_Py_StandardStreamErrors = NULL;
./Python/import.c:static PyObject *extensions = NULL;
./Python/import.c:    static PyObject *builtins_str = NULL;
./Python/import.c:    static PyObject *import_str = NULL;
./Python/sysmodule.c:    static PyObject *newline = NULL;
./Python/_warnings.c:    static PyObject *importlib_string = NULL;
./Python/_warnings.c:    static PyObject *bootstrap_string = NULL;
./Objects/unicodeobject.c:static _PyUnicode_Name_CAPI *ucnhash_capi = NULL;
./Objects/codeobject.c:    static PyObject *emptystring = NULL;
./Objects/codeobject.c:    static PyObject *nulltuple = NULL;
./Objects/listobject.c:static PyObject *indexerr = NULL;
./Objects/exceptions.c:    static PyObject *print_prefix = NULL;
./Objects/exceptions.c:    static PyObject *exec_prefix = NULL;
./Objects/boolobject.c:static PyObject *false_str = NULL;
./Objects/boolobject.c:static PyObject *true_str = NULL;
./Parser/pegen.c:    static void *cache = NULL;
./Modules/_cursesmodule.c:static char *screen_encoding = NULL;
./Modules/arraymodule.c:    static PyObject *array_reconstructor = NULL;
./Modules/_tkinter.c:    static PyObject *tcl_library_path = NULL;
./Modules/_tkinter.c:static PyThreadState *tcl_tstate = NULL;
./Modules/_tkinter.c:static PyThreadState *event_tstate = NULL;
./Modules/syslogmodule.c:static PyObject *S_ident_o = NULL;                      /*  identifier, held by openlog()  */
./Modules/_tracemalloc.c:static PyObject *unknown_filename = NULL;
./Modules/_tracemalloc.c:static _Py_hashtable_t *tracemalloc_filenames = NULL;
./Modules/_tracemalloc.c:static traceback_t *tracemalloc_traceback = NULL;
./Modules/_tracemalloc.c:static _Py_hashtable_t *tracemalloc_tracebacks = NULL;
./Modules/_tracemalloc.c:static _Py_hashtable_t *tracemalloc_traces = NULL;
./Modules/_tracemalloc.c:static _Py_hashtable_t *tracemalloc_domains = NULL;
./Modules/_ssl.c:    static PyObject *x509_asn = NULL;
./Modules/_ssl.c:    static PyObject *pkcs_7_asn = NULL;
./Modules/_ssl.c:static PyThread_type_lock *_ssl_locks = NULL;
./Modules/_testbuffer.c:static PyObject *structmodule = NULL;
./Modules/_testbuffer.c:static PyObject *Struct = NULL;
./Modules/_testbuffer.c:static PyObject *calcsize = NULL;
./Modules/_testbuffer.c:static PyObject *simple_format = NULL;
./Modules/_testbuffer.c:static char *infobuf = NULL;
./Modules/_io/bufferedio.c:    static PyObject *eintr_int = NULL;
./Modules/_asynciomodule.c:static futureiterobject *fi_freelist = NULL;
./Modules/_zoneinfo.c:static PyObject *io_open = NULL;
./Modules/_zoneinfo.c:static PyObject *_tzpath_find_tzfile = NULL;
./Modules/_zoneinfo.c:static PyObject *_common_mod = NULL;
./Modules/_zoneinfo.c:static PyObject *TIMEDELTA_CACHE = NULL;
./Modules/_zoneinfo.c:static PyObject *ZONEINFO_WEAK_CACHE = NULL;
./Modules/_zoneinfo.c:static StrongCacheNode *ZONEINFO_STRONG_CACHE = NULL;
./Modules/_sqlite/microprotocols.c:static PyObject *psyco_adapters = NULL;
./Modules/_ssl/debughelpers.c:    static PyThread_type_lock *lock = NULL;
./Modules/_datetimemodule.c:static PyObject *us_per_ms = NULL;      /* 1000 */
./Modules/_datetimemodule.c:static PyObject *us_per_second = NULL;  /* 1000000 */
./Modules/_datetimemodule.c:static PyObject *us_per_minute = NULL;  /* 1e6 * 60 as Python int */
./Modules/_datetimemodule.c:static PyObject *us_per_hour = NULL;    /* 1e6 * 3600 as Python int */
./Modules/_datetimemodule.c:static PyObject *us_per_day = NULL;     /* 1e6 * 3600 * 24 as Python int */
./Modules/_datetimemodule.c:static PyObject *us_per_week = NULL;    /* 1e6*3600*24*7 as Python int */
./Modules/_datetimemodule.c:static PyObject *seconds_per_day = NULL; /* 3600*24 as Python int */
./Modules/_datetimemodule.c:    static PyObject *module = NULL;
./Modules/_decimal/_decimal.c:static PyObject *tls_context_key = NULL;
./Modules/_decimal/_decimal.c:static PyDecContextObject *cached_context = NULL;
./Modules/_decimal/_decimal.c:static PyObject *current_context_var = NULL;
./Modules/_decimal/_decimal.c:static PyObject *default_context_template = NULL;
./Modules/_decimal/_decimal.c:static PyObject *basic_context_template = NULL;
./Modules/_decimal/_decimal.c:static PyObject *extended_context_template = NULL;
./Modules/_decimal/_decimal.c:static PyObject *DecimalException = NULL;
./Modules/_decimal/_decimal.c:static PyObject *Rational = NULL;
./Modules/_decimal/_decimal.c:static PyTypeObject *DecimalTuple = NULL;
./Modules/_decimal/_decimal.c:    static PyObject *capsule = NULL;
msg389300 - (view) Author: junyixie (JunyiXie) * Date: 2021-03-22 10:31
fix
./Objects/exceptions.c:    static PyObject *print_prefix = NULL;
./Objects/exceptions.c:    static PyObject *exec_prefix = NULL;

https://github.com/python/cpython/pull/24965
msg389304 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-03-22 10:57
Oh. I didn't expect so many "static" variables. I suggest to wait until a PEP is accepted for running multiple interpreters in parallel.
msg389310 - (view) Author: junyixie (JunyiXie) * Date: 2021-03-22 13:16
Okay, I will fix these problems first. (Need for your own project)
msg389311 - (view) Author: junyixie (JunyiXie) * Date: 2021-03-22 13:16
-> Okay, I will fix these problems first. (Need for my own project)
msg389322 - (view) Author: junyixie (JunyiXie) * Date: 2021-03-22 14:18
I will fix the static variable problem of frequently used code
msg389323 - (view) Author: Dong-hee Na (corona10) * (Python committer) Date: 2021-03-22 14:25
@JunyiXie

Please wait your patch until the PEP is approved.
msg389324 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-03-22 14:33
Until the PEP is accepted, you can start working on a branch if you want. You can post the link to your branch.
msg406069 - (view) Author: junyixie (JunyiXie) * Date: 2021-11-10 03:34
About PEP
How is the progress? Where can I track it? Is there any relevant plan?
thanks
msg406080 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-11-10 10:22
So far, no PEP has been written.
msg416918 - (view) Author: Kumar Aditya (kumaraditya) * (Python triager) Date: 2022-04-07 08:17
Most of the static variables were removed by GH-31366 so I closed those PRs as they were outdated, however some static variable still exist.
History
Date User Action Args
2022-04-11 14:59:43adminsetgithub: 87754
2022-04-07 08:17:57kumaradityasetnosy: + kumaraditya
messages: + msg416918
2021-11-10 10:22:49vstinnersetmessages: + msg406080
2021-11-10 09:01:13shihai1991setnosy: + shihai1991
2021-11-10 03:34:53JunyiXiesetmessages: + msg406069
2021-03-22 20:31:42JunyiXiesetpull_requests: + pull_request23739
2021-03-22 20:31:03JunyiXiesetpull_requests: + pull_request23738
2021-03-22 14:33:57vstinnersetmessages: + msg389324
2021-03-22 14:25:54corona10setnosy: + corona10
messages: + msg389323
2021-03-22 14:18:16JunyiXiesetmessages: + msg389322
2021-03-22 13:41:57JunyiXiesetpull_requests: + pull_request23729
2021-03-22 13:19:42JunyiXiesetpull_requests: + pull_request23728
2021-03-22 13:16:40JunyiXiesetmessages: + msg389311
2021-03-22 13:16:22JunyiXiesetmessages: + msg389310
2021-03-22 13:05:26JunyiXiesetpull_requests: + pull_request23727
2021-03-22 10:57:32vstinnersetmessages: + msg389304
2021-03-22 10:32:53JunyiXiesetpull_requests: + pull_request23726
2021-03-22 10:31:04JunyiXiesetmessages: + msg389300
2021-03-22 10:15:28JunyiXiesetpull_requests: + pull_request23724
2021-03-22 09:58:12JunyiXiesetmessages: + msg389292
2021-03-22 08:20:23JunyiXiesetmessages: + msg389284
pull_requests: + pull_request23722
2021-03-22 08:18:41JunyiXiesetkeywords: + patch
stage: patch review
pull_requests: + pull_request23720
2021-03-22 08:09:32JunyiXiecreate