Skip to content

Conversation

duaneg
Copy link
Contributor

@duaneg duaneg commented Apr 20, 2025

The dbm_* functions are not thread-safe, naturally. Add critical sections to protect their use.

The dbm_* functions are not thread-safe, naturally. Add critical sections to
protect their use.
@picnixz picnixz changed the title gh-127081: add critical sections to dbm objects gh-127081: add critical sections to dbm objects Apr 20, 2025
Copy link
Member

@ZeroIntensity ZeroIntensity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, it's easier to add lock_held variations of functions instead of adding inline critical sections with goto. For example:

static int
dbm_something_lock_held(PyObject *self)
{
    /* ... */
}

static int
dbm_something(PyObject *self)
{
    int result;
    Py_BEGIN_CRITICAL_SECTION(self);
    result = dbm_something_lock_held(self);
    Py_END_CRITICAL_SECTION();
    return result;
}

Would you mind switching over to that pattern here?

@duaneg
Copy link
Contributor Author

duaneg commented Apr 20, 2025

In general, it's easier to add lock_held variations of functions instead of adding inline critical sections with goto.... Would you mind switching over to that pattern here?

For sure, that would be much more robust, thanks!

@corona10 corona10 self-assigned this Apr 23, 2025
@corona10
Copy link
Member

Sorry for the delay, I will review during the PyCon sprint.

Copy link
Member

@ZeroIntensity ZeroIntensity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM as well

@corona10
Copy link
Member

스크린샷 2025-05-14 오후 1 47 57

Would you like to update clinic again?

@corona10
Copy link
Member

Oh it's not relatede to dbms.

@corona10 corona10 merged commit ffaeb3d into python:main May 14, 2025
39 checks passed
Pranjal095 pushed a commit to Pranjal095/cpython that referenced this pull request Jul 12, 2025
taegyunkim pushed a commit to taegyunkim/cpython that referenced this pull request Aug 4, 2025
@kumaraditya303 kumaraditya303 added the needs backport to 3.14 bugs and security fixes label Oct 12, 2025
@miss-islington-app
Copy link

Thanks @duaneg for the PR, and @corona10 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 12, 2025
)

(cherry picked from commit ffaeb3d)

Co-authored-by: Duane Griffin <duaneg@dghda.com>
@bedevere-app
Copy link

bedevere-app bot commented Oct 12, 2025

GH-139996 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Oct 12, 2025
kumaraditya303 pushed a commit that referenced this pull request Oct 12, 2025
…139996)

gh-127081: add critical sections to `dbm` objects (gh-132749)
(cherry picked from commit ffaeb3d)

Co-authored-by: Duane Griffin <duaneg@dghda.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants