Skip to content
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

gh-112069: Do not require lock if the set has never been exposed. #118069

Merged
merged 3 commits into from
Apr 25, 2024

Conversation

corona10
Copy link
Member

@corona10 corona10 commented Apr 18, 2024

@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @corona10 for commit 50d62bd 🤖

If you want to schedule another build, you need to add the 🔨 test-with-refleak-buildbots label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-refleak-buildbots Test PR w/ refleak buildbots; report in status section label Apr 18, 2024
@@ -2334,6 +2334,12 @@ set_init(PySetObject *self, PyObject *args, PyObject *kwds)
if (!PyArg_UnpackTuple(args, Py_TYPE(self)->tp_name, 0, 1, &iterable))
return -1;

if (self->fill == 0 && Py_REFCNT(self) == 1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should do the Py_REFCNT() check first so that we don't access self->fill without a lock in case there are other threads with references modifying self.

Also, do we need to set self->hash = -1 as we do below?

Copy link
Member Author

Choose a reason for hiding this comment

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

Also, do we need to set self->hash = -1 as we do below?

Well it will be more safe.

@corona10 corona10 requested a review from colesbury April 20, 2024 00:55
@rhettinger rhettinger removed their request for review April 21, 2024 19:11
@corona10
Copy link
Member Author

@colesbury gentle ping :)

Copy link
Contributor

@colesbury colesbury left a comment

Choose a reason for hiding this comment

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

Thanks!

@corona10 corona10 merged commit eb20a7d into python:main Apr 25, 2024
36 checks passed
@corona10 corona10 deleted the gh-112069-init branch April 25, 2024 15:14
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.

None yet

3 participants