Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

PyDict_Next should not lock the dict #120858

Closed
Labels
3.13bugs and security fixes3.14bugs and security fixestopic-free-threadingtype-bugAn unexpected behavior, bug, or error
@colesbury

Description

@colesbury

Bug report

PyDict_Next currently wraps_PyDict_Next in a critical section. We shouldn't do this -- the locking needs to be external to the call.

  1. It's not sufficient to lock the dict just for each_PyDict_Next call because we return borrowed references and becausepos becomes meaningless if the dictionary gets resized or rehashed.
  2. It interferes with externally locking the dict because the inner critical sections can suspend the outer ones. In other words, if the caller use a critical section to lock the dict for multiple iterations, this will break that.

PyDict_Next(PyObject*op,Py_ssize_t*ppos,PyObject**pkey,PyObject**pvalue)
{
intres;
Py_BEGIN_CRITICAL_SECTION(op);
res=_PyDict_Next(op,ppos,pkey,pvalue,NULL);
Py_END_CRITICAL_SECTION();
returnres;
}

cc@DinoV

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixes3.14bugs and security fixestopic-free-threadingtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp