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

GH-116008: Aquire TState and StopTheWorld in faulthandler_user#141267

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
sergey-miryanov wants to merge2 commits intopython:main
base:main
Choose a base branch
Loading
fromsergey-miryanov:116008-safe-faulthandler-register

Conversation

@sergey-miryanov
Copy link
Contributor

@sergey-miryanovsergey-miryanov commentedNov 8, 2025
edited by bedevere-appbot
Loading

Trying to be a bit safer for non-fatal signals

@sergey-miryanov
Copy link
ContributorAuthor

@vstinner Could you please take a look?

@sergey-miryanovsergey-miryanov requested review fromAA-Turner andefimov-mikhail and removed request forAA-TurnerNovember 8, 2025 18:58
@sergey-miryanov
Copy link
ContributorAuthor

@AA-Turner sorry, misclick.

AA-Turner reacted with thumbs up emoji

Copy link
Member

@ZeroIntensityZeroIntensity left a comment

Choose a reason for hiding this comment

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

We can't acquire the GIL or make a stop-the-world pause inside signal handlers, because they're not signal safe. For example, Python could receive the signal while in the middle of a stop-the-world pause, which would deadlock inside the signal handler.

@bedevere-app
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phraseI have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

And if you don't make the requested changes, you will be poked with soft cushions!

@sergey-miryanov
Copy link
ContributorAuthor

@ZeroIntensity If I get you right (feel free to correct me):

  1. _PyThreadState_Attach is not signal-safe. If we call_PyThreadState_Attach from withinfaulthandler_user then another signal can callfaulthandler_user again and this led to undefined state. IIUC, we can handle this with thereentrant flag, asfaulthandler_dump_traceback did.
  2. _PyEval_StopTheWorld is not signal-safe too. If we already in the stop-the-world state then calling_PyEval_StopTheWorld again will lead to deadlock onstoptheworld_mutex. And we can't handle this without changing the semantics of_PyEval_StopTheWorld. I don't intend to do this.

Therefore, if we want to safely handle non-fatal signals, then using thesignal module seems like the only option. Or leave them as-is.

@ZeroIntensity
Copy link
Member

IIUC, we can handle this with the reentrant flag, as faulthandler_dump_traceback did.

Nope, because_PyThreadState_Attach will also try to acquire locks, leading to a deadlock if they're called under a signal.

I think it would be best to just document that faulthandler sometimes crashes if you mess with it.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@ZeroIntensityZeroIntensityZeroIntensity requested changes

@efimov-mikhailefimov-mikhailAwaiting requested review from efimov-mikhail

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@sergey-miryanov@ZeroIntensity

[8]ページ先頭

©2009-2025 Movatter.jp