Skip to content

gh-123828: fix data raceing for _waiting_release method in _interpchannelsmodule.c - #124107

Merged
ZeroIntensity merged 9 commits into
python:mainfrom
Zheaoli:manjusaka/fix-123828
Oct 1, 2025
Merged

ZeroIntensity merged 9 commits into
python:mainfrom
Zheaoli:manjusaka/fix-123828

Conversation

@Zheaoli

@Zheaoli Zheaoli commented Sep 15, 2024 •

Copy link
Copy Markdown
Contributor
…erpchannelsmodule.c

Signed-off-by: Manjusaka <me@manjusaka.me>
@Zheaoli
Zheaoli force-pushed the manjusaka/fix-123828 branch from d8a89c1 to ffee4ed Compare September 15, 2024 17:36
@Zheaoli Zheaoli changed the title gh-13828: fix data raceing for _waiting_release method in _interpchan… Sep 15, 2024
Comment thread Modules/_interpchannelsmodule.c Resolved
@ZeroIntensity

Copy link
Copy Markdown
Member

@picnixz out of the scope of this PR, but would it be feasible to migrate things using PyThread locks over to PyMutex in the future?

@picnixz

picnixz commented Sep 17, 2024

Copy link
Copy Markdown
Member

Maybe. Haven't had the time to think about it and I don't know if it's possible for every case. Could you open another issue for that? also how would performances / maintenance cost be impacted?

@ZeroIntensity

Copy link
Copy Markdown
Member

Maybe. Haven't had the time to think about it and I don't know if it's possible for every case. Could you open another issue for that? also how would performances / maintenance cost be impacted?

It's probably worth discussing on discourse before opening an issue. AFAIK, PyMutex is supposed to be much more efficient than pthread mutexes.

Signed-off-by: Manjusaka <me@manjusaka.me>
@Zheaoli

Zheaoli commented Sep 27, 2025

Copy link
Copy Markdown
Contributor Author

@picnixz May I ask if this pr is worth to merge?

@picnixz

picnixz commented Sep 27, 2025

Copy link
Copy Markdown
Member

I am not well-versed enough in this part of the code to be sure that it's correct, so I'll let Eric decide (or @ZeroIntensity)

@ZeroIntensity

Copy link
Copy Markdown
Member

The core change looks correct, I noticed this with Eric at the sprint. Please add a test though.

@Zheaoli

Zheaoli commented Sep 27, 2025

Copy link
Copy Markdown
Contributor Author

The core change looks correct, I noticed this with Eric at the sprint. Please add a test though.

Sorry about this. I have noticed that seems We don't have tests for the data race before(correct me if I'm wrong). You mean that we enable some test in CI?

@ZeroIntensity

Copy link
Copy Markdown
Member

Just add something that stresses this concurrently, we'll get around to enabling TSan on test_interpreters later.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we should remove this news entry. _interpchannels isn't exposed to any user-facing API.

@Zheaoli

Zheaoli commented Sep 28, 2025

Copy link
Copy Markdown
Contributor Author

Just add something that stresses this concurrently, we'll get around to enabling TSan on test_interpreters later.

This issue is triggered by TSAN test. So I think if we don't need add more test if we are planning to enable TSAN

@picnixz

picnixz commented Sep 28, 2025

Copy link
Copy Markdown
Member

I think @ZeroIntensity wanted add a test that specifically triggers it, not one that indirectly triggers it.

Signed-off-by: Manjusaka <me@manjusaka.me>
Signed-off-by: Manjusaka <me@manjusaka.me>
@Zheaoli
Zheaoli marked this pull request as draft September 28, 2025 12:38
Signed-off-by: Manjusaka <me@manjusaka.me>
Signed-off-by: Manjusaka <me@manjusaka.me>
@Zheaoli
Zheaoli marked this pull request as ready for review September 28, 2025 13:14
@Zheaoli

Zheaoli commented Sep 28, 2025

Copy link
Copy Markdown
Contributor Author

@ZeroIntensity @picnixz Actually I think we don't need new tests anymore. In #129824, we found that the current test will triger the TSAN report. And this PR can fix the test and I reenable the test now

@ZeroIntensity ZeroIntensity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ok, thanks, this looks good.

@ericsnowcurrently This is the race I was telling you about at the sprints. As far as I can tell, this is the only thing blocking test_interpreters from running on the free-threaded build.

@ZeroIntensity
ZeroIntensity enabled auto-merge (squash) October 1, 2025 11:03
@ZeroIntensity
ZeroIntensity merged commit f39dea3 into python:main Oct 1, 2025
@Zheaoli

Zheaoli commented Oct 1, 2025

Copy link
Copy Markdown
Contributor Author

The test has been failed https://buildbot.python.org/#/builders/75/builds/3415

I'm trying to figure it out

@Zheaoli
Zheaoli deleted the manjusaka/fix-123828 branch October 1, 2025 13:06
@ZeroIntensity

Copy link
Copy Markdown
Member

That might be the leak from #139073.

@ericsnowcurrently

Copy link
Copy Markdown
Member

Any reason not to backport this to 3.14?

@ZeroIntensity

Copy link
Copy Markdown
Member

I didn't think it was that big of a deal because _interpchannels is only used in tests at the moment, but I don't mind backporting it. We'll have to wait until 3.14.1 because 3.14 is currently locked down for the RC, though.

@ZeroIntensity ZeroIntensity added the needs backport to 3.14 bugs and security fixes label Oct 2, 2025
@miss-islington-app

Copy link
Copy Markdown

Thanks @Zheaoli for the PR, and @ZeroIntensity for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 2, 2025
…ythonGH-124107)

(cherry picked from commit f39dea3)

Co-authored-by: Nadeshiko Manju <me@manjusaka.me>
@bedevere-app

bedevere-app Bot commented Oct 2, 2025

Copy link
Copy Markdown

GH-139517 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 2, 2025
ZeroIntensity pushed a commit that referenced this pull request Oct 7, 2025
…GH-124107) (GH-139517)

gh-123828: Fix data race in `_interpchannels._waiting_release` (GH-124107)
(cherry picked from commit f39dea3)

Co-authored-by: Nadeshiko Manju <me@manjusaka.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

4 participants