Repository navigation
gh-162251: Wait for child execve before creating RemoteUnwinder - #162268
Conversation
RemoteUnwinderRemoteUnwinder
| """ | ||
| with _managed_subprocess([sys.executable, "-c", script]) as process: | ||
| # On Linux, wait until execve() replaced the forked process image. | ||
| if sys.platform == "linux": |
There was a problem hiding this comment.
It would be nice if we could find a portable solution to fix also the issue on other platforms.
There was a problem hiding this comment.
Thanks! I think the portable solution is the earlier socket-communication version in this PR. The child sends a b"ready" signal, which can only happen after execve(). It works on Linux/macOS/Windows. I'm happy to switch back to that version if you prefer portability.
Co-authored-by: Victor Stinner <vstinner@python.org>
|
@tanloong @vstinner Can we try with self._target_process(script) as (process, _, _):
unwinder = RemoteUnwinder(
process.pid, native=True, gc=False, cache_frames=False,
)Also, getting rid of the whole cc @pablogsal |
|
@maurycy That's much cleaner! I'd like to switch to |
|
_target_process() API looks cleaner and more portable than reading /proc/pid/cmdline. Yeah we should reuse that. |
|
Updated to reuse There are other places in |
vstinner
left a comment
There was a problem hiding this comment.
LGTM.
You might reuse _target_process() make_unwinder (3rd argument), but it would require to add new optional arguments to make_unwinder(). I'm not sure that it's worth it. It's ok to use RemoteUnwinder directly.
It seems like only test_popping_python_frame_is_not_native() used directly _managed_subprocess() without synchronization with the child process. So we should be good with this change.
|
Python 3.15 is not affected: it doesn't have the test. |
|
Merged. Thanks for the fix! |
Explained in #162251 (comment).
Adds socket communication following the pattern used by other tests in
test_external_inspection.py. I confirmed the timeout error appears onmainand disappears with the change.