FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-131591: Implement PEP 768 by pablogsal · Pull Request #131592 · python/cpython · GitHub

/ cpython Public

gh-131591: Implement PEP 768 - #131592

Closed
pablogsal wants to merge 39 commits into
python:mainfrom
pablogsal:main
Closed

gh-131591: Implement PEP 768#131592
pablogsal wants to merge 39 commits into
python:mainfrom
pablogsal:main

Conversation

pablogsal commented Mar 22, 2025
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

Copy link
Copy Markdown
Member Author

CC: @godlygeek @ivonastojanovic

ghost commented Mar 25, 2025
edited by ghost
Loading

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

Comment thread Python/initconfig.c
Comment thread Python/initconfig.c

godlygeek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Initial observations (I've looked at everything but the interesting stuff, haven't gotten to Python/remote_debugging.c or Lib/test/test_sys.py yet)

Comment thread Include/cpython/pystate.h Outdated
Comment thread Include/cpython/pystate.h Outdated
Comment thread Python/ceval_gil.c Outdated
Comment thread Python/ceval_gil.c Outdated
Comment thread Python/sysmodule.c Outdated
Comment thread Python/sysmodule.c Outdated
Comment thread Python/sysmodule.c
Comment thread Python/sysmodule.c Outdated
ivonastojanovic and others added 17 commits March 28, 2025 18:14
The PyRuntime section can be found in either the main executable (python.exe) or the Python DLL (pythonXY.dll, where X and Y represent the major and minor version numbers). Scan the modules of the process to locate the PyRuntime address in one of these modules.
Ensure that the caller and target processes have matching architectures
before proceeding. Attaching to a 64-bit process from a 32-bit process
will fail when using CreateToolhelp32Snapshot, and attempting to attach
to a 32-bit process from a 64-bit process may cause issues during PE
file parsing. To avoid potential errors abort the operation if the
architectures differ.
This reverts commit 746ecfc.

That commit isn't correct. It conflates the return from `IsWow64Process`
(whether the process is running under 32-bit emulation on a 64-bit
process) with whether the process is 64-bit. A 32-bit process on 32-bit
Windows would have `IsWow64Process` set our `isWow64` flag to `FALSE`,
and we'd then incorrectly return `TRUE` from `is_process64Bit`.
This is useful because debuggers will write to this variable remotely,
and it's helpful for it to have a well known size rather than one that
could vary per platform.
Require the flags for turning this on to be set to exactly 1 to avoid
accidentally triggering remote debugging in the case of heap corruption.
Make a heap copy of the script path before using it to avoid the buffer
being overwritten while we're still using it by another debugger.
This avoids the need to reopen it by (wide character) path.
Previously it was leaked if `PyObject_AsFileDescriptor` failed.
I think this was a copy paste error.
The remote process must be a compatible version.

Explain our compatibility rules.
We can clean this up by freeing strings as soon as we're done with them,
and remove some duplicate code.
This was documented as working, but in fact we assumed that the path
would always be a unicode string. Factor the version that only accepts a
unicode string into a helper function, and have the caller call
`os.fsdecode` on the input path, which accepts either a byte string or a
unicode string and always returns a unicode string.
Previously we were returning the number of bytes, which we didn't need
and would never be different than the argument that was passed into the
function.
This field in the structure is defined as an `unsigned long`, not as
a `pid_t`.
We already did a `strlen` on the `debugger_script_path`, so it's too late
to check if it's NULL here!
This helps to harden a bit against heap corruption.
pablogsal marked this pull request as ready for review March 29, 2025 11:38
Comment thread Lib/test/test_sys.py Outdated
Comment thread Lib/test/test_sys.py Outdated
pablogsal added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Mar 31, 2025

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @pablogsal for commit 80856d3 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F131592%2Fmerge

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

bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Mar 31, 2025

Copy link
Copy Markdown
Member Author

I'm going to close this and reopen because the CI got stuck somehow

pablogsal closed this Mar 31, 2025

Copy link
Copy Markdown
Member Author

#131937

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

5 participants


Back | FazBrowse Home | New Git URL