FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

BUG: fix stringdtype singleton thread safety by charris · Pull Request #28864 · numpy/numpy · GitHub

/ numpy Public

BUG: fix stringdtype singleton thread safety - #28864

Merged
charris merged 2 commits into
numpy:maintenance/2.2.xfrom
charris:backport-28862
Apr 29, 2025
Merged

charris merged 2 commits into
numpy:maintenance/2.2.xfrom
charris:backport-28862

Conversation

charris commented Apr 29, 2025

Copy link
Copy Markdown
Member

Backport of #28862.

Fixes #28813.

Two orthogonal but related fixes.

First, to guard against newly created StringDType instances being shared between threads, we acquire the allocator lock before reading and possibly setting the array_owned flag on a descriptor passed to the descriptor finalization function.

Second, I completely removed the singleton for StringDType. Since StringDType uses per-array descriptors, we're always going to need to create a new descriptor for each array anyway. We probably don't want an array to use a globally shared instance either. The tests pass with no other changes to the codebase besides deleting the code that creates the singleton, so I think it's not needed for anything either.

Not sure if we're going to do another 2.2.x, but I think this is also safe to backport.

charris added 00 - Bug 08 - Backport Used to tag backport PRs component: numpy.strings String dtypes and functions 39 - free-threading PRs and issues related to support for free-threading CPython (a.k.a. no-GIL, PEP 703) labels Apr 29, 2025
charris added this to the 2.2.6 release milestone Apr 29, 2025
charris merged commit 5870d71 into numpy:maintenance/2.2.x Apr 29, 2025
charris deleted the backport-28862 branch April 29, 2025 20:47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

00 - Bug 08 - Backport Used to tag backport PRs 39 - free-threading PRs and issues related to support for free-threading CPython (a.k.a. no-GIL, PEP 703) component: numpy.strings String dtypes and functions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL