Skip to content
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

unicode: make ucnhash_capi initialization thread-safe in --disable-gil builds #111972

Closed
Tracked by #108219
colesbury opened this issue Nov 10, 2023 · 2 comments · Fixed by #112249
Closed
Tracked by #108219

unicode: make ucnhash_capi initialization thread-safe in --disable-gil builds #111972

colesbury opened this issue Nov 10, 2023 · 2 comments · Fixed by #112249
Assignees
Labels
3.13 bugs and security fixes topic-free-threading type-feature A feature request or enhancement

Comments

@colesbury
Copy link
Contributor

colesbury commented Nov 10, 2023

Feature or enhancement

The _PyUnicode_Name_CAPI provides functions to get the name for a given Unicode character code and vice versa. It is lazily initialized and stored in the per-interpreter _Py_unicode_state:

struct _Py_unicode_state {
struct _Py_unicode_fs_codec fs_codec;
_PyUnicode_Name_CAPI *ucnhash_capi;
// Unicode identifiers (_Py_Identifier): see _PyUnicode_FromId()
struct _Py_unicode_ids ids;
};

The initialization of the ucnhash_capi isn't thread-safe without the GIL. (There can be a data race on reading and writing ucnhash_capi).

Mostly for my own reference, here are the similar modifications in the nogil-3.12 fork: colesbury/nogil-3.12@5d006db9fa

Linked PRs

@Eclips4
Copy link
Member

Eclips4 commented Nov 18, 2023

This seems quite easy 😄
Please, take a look at the #112249.

@erlend-aasland
Copy link
Contributor

Resolved by #112249

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes topic-free-threading type-feature A feature request or enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants