Skip to content

Conversation

@vstinner
Copy link
Member

@vstinner vstinner commented Oct 27, 2025

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

LGTM. 👍

@vstinner
Copy link
Member Author

Calling OpenThread(), GetThreadDescription() and _Py_EncodeLocaleRaw() is not async signal-safe. For example, _Py_EncodeLocaleRaw() allocates memory on the heap memory. But on Windows, signal handlers are called in a temporary thread. So it should be ok to call these functions in faulthandler signal handlers.

Copy link
Contributor

@sergey-miryanov sergey-miryanov left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@vstinner vstinner merged commit 313145e into python:main Oct 27, 2025
51 checks passed
@vstinner vstinner deleted the faulthandler_thread_name_windows branch October 27, 2025 17:41
@vstinner
Copy link
Member Author

vstinner commented Oct 27, 2025

Ok, let's see how it goes. Merged, thanks for reviews.

I'm not confident in this code, so I prefer to not backport it to 3.14.1. Also, it can be seen as a new feature rather than a bugfix.

vstinner added a commit to vstinner/cpython that referenced this pull request Nov 27, 2025
vstinner added a commit that referenced this pull request Nov 27, 2025
…2011)

* gh-125434: Display thread name in faulthandler on Windows (#140675)

(cherry picked from commit 313145e)

* gh-125434: Fix non-ASCII thread names in faulthandler on Windows (#140700)

Add _Py_DumpWideString() function to dump a wide string as ASCII. It
supports surrogate pairs.

Replace _Py_EncodeLocaleRaw() with _Py_DumpWideString()
in write_thread_name().

(cherry picked from commit 80f20f5)
StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull request Dec 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants