Skip to content

BUG: fix thread safety of array_getbuffer (#30667)#30736

Merged
charris merged 2 commits intonumpy:maintenance/2.4.xfrom
charris:backport-30667
Jan 27, 2026
Merged

BUG: fix thread safety of array_getbuffer (#30667)#30736
charris merged 2 commits intonumpy:maintenance/2.4.xfrom
charris:backport-30667

Conversation

@charris
Copy link
Member

@charris charris commented Jan 27, 2026

Backport of #30667.

Add critical sections around buffer info creation/mutation.

Fixes #30648

Add critical sections around buffer info creation/mutation.
@charris charris added this to the 2.4.2 release milestone Jan 27, 2026
@charris charris added 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) labels Jan 27, 2026
@charris
Copy link
Member Author

charris commented Jan 27, 2026

Looks like this needs an inspect fixup. @jorenham IIRC, you were involved in that.

@charris
Copy link
Member Author

charris commented Jan 27, 2026

Actually, looks like the problem is Python 3.11.

@jorenham
Copy link
Member

Looks like this needs an inspect fixup. @jorenham IIRC, you were involved in that.

inspect.BufferFlags was added in Python 3.12 (https://docs.python.org/3/library/inspect.html#inspect.BufferFlags). It's an IntEnum, and looking at the source code, STRIDED can be replaced with 25, STRIDES with 24, and READ with 256, i.e. flags=[25, 256] and flags=[24, 256] for the first and second added tests, respectively.

@charris
Copy link
Member Author

charris commented Jan 27, 2026

Thanks Joren, let's give that a shot.

@jorenham
Copy link
Member

Hmmm, I guess we should just disable these tests completely on Python<3.12

@charris charris merged commit 7ff9863 into numpy:maintenance/2.4.x Jan 27, 2026
73 checks passed
@charris charris deleted the backport-30667 branch January 27, 2026 21:08
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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants