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 — list iterator and list reverse iterator are not thread safe · Issue #130263 · python/cpython

list iterator and list reverse iterator are not thread safe #130263

New issue
Copy link
New issue
Copy link
Closed
Closed
list iterator and list reverse iterator are not thread safe#130263
Copy link
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-free-threading

Description

@kumaraditya303
kumaraditya303
opened on Feb 18, 2025
Issue body actions

While reviewing #130096, I checked the thread safety of list object and there at some places we are missing atomic stores of index.

Specifically the following:

  • cpython/Objects/listobject.c

    Lines 3994 to 3997 in 97d0011

    else if (index > PyList_GET_SIZE(it->it_seq))
    index = PyList_GET_SIZE(it->it_seq); /* iterator exhausted */
    it->it_index = index;
    }
  • cpython/Objects/listobject.c

    Lines 4146 to 4149 in 97d0011

    else if (index > PyList_GET_SIZE(it->it_seq) - 1)
    index = PyList_GET_SIZE(it->it_seq) - 1;
    it->it_index = index;
    }

They should use atomic relaxed stores.

Linked PRs

  • gh-130263: fix list iterators to use atomics for storing index #130266

Activity

  1. kumaraditya303
    added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    topic-free-threading
    on Feb 18, 2025
  2. kumaraditya303 commented on Feb 19, 2025

    @kumaraditya303
    kumaraditya303
    on Feb 19, 2025
    ContributorAuthor
    More actions

    Fixed by 388e1ca

  3. kumaraditya303
    closed this as completedon Feb 19, 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

    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-free-threading

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — 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.