Content-Length: 262631 | pFad | http://github.com/numpy/numpy/issues/29086

76 BUG: thread safety issue in f2py implementation · Issue #29086 · numpy/numpy · GitHub
Skip to content

BUG: thread safety issue in f2py implementation #29086

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

Closed
ngoldbaum opened this issue May 29, 2025 · 3 comments · Fixed by #29091
Closed

BUG: thread safety issue in f2py implementation #29086

ngoldbaum opened this issue May 29, 2025 · 3 comments · Fixed by #29091
Labels
00 - Bug 39 - free-threading PRs and issues related to support for free-threading CPython (a.k.a. no-GIL, PEP 703) component: numpy.f2py
Milestone

Comments

@ngoldbaum
Copy link
Member

@crusaderky tracked down a thread safety issue over in SciPy to code generated by f2py. See scipy/scipy#21936 (comment).

Lo and behold, there's a static struct I missed when I went over the f2py codebase last year:

static struct { int nd;npy_intp *d;int *i,*i_tr,tr; } forcombcache;

I think the simplest fix is probably to make the struct thread-local. @crusaderky told me they were working on an isolated test case to trigger the issue they hit and a patch.

@ngoldbaum ngoldbaum added 00 - Bug component: numpy.f2py 39 - free-threading PRs and issues related to support for free-threading CPython (a.k.a. no-GIL, PEP 703) labels May 29, 2025
@charris charris added this to the 2.3.0 release milestone May 29, 2025
@seberg
Copy link
Member

seberg commented May 30, 2025

Feels like this should just be a stack variable where it is used, rather than a global static. But of course I am not even sure what the function does on first sight :).

@HaoZeke
Copy link
Member

HaoZeke commented May 30, 2025

AFAIK it's used to iterate over entries in column major... I think it could actually be refactored into a stack variable, but probably easier to make it thread local first.

@crusaderky
Copy link
Contributor

#29091 changes it to a stack variable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
00 - Bug 39 - free-threading PRs and issues related to support for free-threading CPython (a.k.a. no-GIL, PEP 703) component: numpy.f2py
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/numpy/numpy/issues/29086

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy