GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — BUG: thread safety issue in f2py implementation · Issue #29086 · numpy/numpy

BUG: thread safety issue in f2py implementation #29086

New issue
Copy link
New issue
Copy link
Closed
#29091
Closed
BUG: thread safety issue in f2py implementation#29086
#29091
Copy link
Labels
00 - Bug39 - free-threadingPRs and issues related to support for free-threading CPython (a.k.a. no-GIL, PEP 703)component: numpy.f2py
Milestone
2.3.0 release

Description

@ngoldbaum
ngoldbaum
opened on May 29, 2025
Issue body actions

@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:

numpy/numpy/f2py/cfuncs.py

Line 601 in b37f761

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.

Activity

  1. ngoldbaum
    added
    00 - Bug
    component: numpy.f2py
    39 - free-threadingPRs and issues related to support for free-threading CPython (a.k.a. no-GIL, PEP 703)
    on May 29, 2025
  2. charris
    added this to the 2.3.0 release milestone on May 29, 2025
  3. seberg commented on May 30, 2025

    @seberg
    seberg
    on May 30, 2025
    Member
    More actions

    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 :).

  4. HaoZeke commented on May 30, 2025

    @HaoZeke
    HaoZeke
    on May 30, 2025
    Member
    More actions

    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.

  5. crusaderky commented on May 30, 2025

    @crusaderky
    crusaderky
    on May 30, 2025
    Contributor
    More actions

    #29091 changes it to a stack variable

  6. seberg
    closed this as completedin #29091on May 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    00 - Bug39 - free-threadingPRs and issues related to support for free-threading CPython (a.k.a. no-GIL, PEP 703)component: numpy.f2py

    Type

    No type

    Projects

    No projects

      Milestone

      • 2.3.0 release

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.