-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
_PyUnicode_Fini should invalidate ucnhash_capi capsule pointer #91338
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
Comments
unicodeobject.c has a static pointer to a unicode name CAPI capsule: static _PyUnicode_Name_CAPI *ucnhash_capi = NULL; The capsule is initialized on demand when the parser encounters a named unicode representation like "\N{digit nine}". Once the capsule pointer ucnhash_capi has been initialized, it is never reset. Not even a full interpreter shutdown invalidates the pointer. A shutdown of the main interpreter with Py_Finalize() renders the pointer invalid. If the interpreter is re-initialized again, the invalid pointer causes a segfault. The problem was first discovered by Trey Hunner in emmatyping/python-wasm#69 python.js:219 Uncaught RuntimeError: null function or function signature mismatch I can reproduce the issue with pure C code: $ gcc -Xlinker -export-dynamic -g -IInclude/ -I. -o ucnbug ucnbug.c libpython3.11.a -lm -ldl
$ gdb ucnbug
(gdb) run
0
9
Done 1 Program received signal SIGSEGV, Segmentation fault. |
Fixed by #32212 |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: