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

python -m pdb -p fails when CONFIG_CROSS_MEMORY_ATTACH not set in kernel config #134876

Closed
Labels
3.14bugs and security fixes3.15new features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error
@cakemanny

Description

@cakemanny

Bug report

Bug description:

It's possible that a Linux kernel is built with the kernel config variableCONFIG_CROSS_MEMORY_ATTACH not set. (This is the case for the kernel that comes with Flatcar Container Linux and for CoreOS, the former of which is used for kubernetes nodes by the cloud provider we use).

In this case, usingpython -m pdb <some python PID> fails and it looks like this:

root@bc6b29d0894d:/src/cpython# ./python -c$'import time;\nwhile True: time.sleep(1)'&[1] 17106root@bc6b29d0894d:/src/cpython# ./python -m pdb -p$!OSError: [Errno 38] Function not implementedThe above exception was the direct cause of the following exception:OSError: process_vm_readv failedfor PID 17106 at address 0xaaaab1f8d038 (size 760, partialread 0 bytes): Function not implementedThe above exception was the direct cause of the following exception:Traceback (most recent call last):  File"/src/cpython/Lib/runpy.py", line 198,in _run_module_as_mainreturn _run_code(code, main_globals, None,"__main__", mod_spec)  File"/src/cpython/Lib/runpy.py", line 88,in _run_code    exec(code, run_globals)~~~~^^^^^^^^^^^^^^^^^^^  File"/src/cpython/Lib/pdb.py", line 3609,in<module>pdb.main()~~~~~~~~^^  File"/src/cpython/Lib/pdb.py", line 3540,in main    attach(opts.pid, opts.commands)~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^  File"/src/cpython/Lib/pdb.py", line 3424,in attach    sys.remote_exec(pid, connect_script.name)~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^RuntimeError: Failed toread debug offsets structure from remote process

This is a single command to repro on such a system

docker run -i --rm python:3.13 bash<< 'EOF'  # the python version here is irrelevant, the image just has the right depsnewresolv=$(sed $'/nameserver/i\\\nnameserver 1.1.1.1' /etc/resolv.conf); echo "$newresolv" > /etc/resolv.conf  # resolv is wrong in my repro VMmkdir src && cd srcgit clone https://github.com/python/cpython.git --depth=10  # add --branch=3.14 to test 3.14cd cpython./configure --with-pydebug && make -j $(nproc)./python -c $'import time;\nwhile True: time.sleep(1)' &./python -m pdb -p $!EOF

Further relevant version info for the above repro output:

root@bc6b29d0894d:/src/cpython# uname -aLinux bc6b29d0894d 6.6.88-flatcar #1 SMP PREEMPT Tue Apr 29 23:08:45 -00 2025 aarch64 GNU/Linuxroot@bc6b29d0894d:/src/cpython# ./python -VVPython 3.15.0a0 (heads/main:e64395e, May 29 2025, 09:16:22) [GCC 12.2.0]root@bc6b29d0894d:/src/cpython# git show | head -1commit e64395e8eb8d3a9e35e3e534e87d427ff27ab0a5root@bc6b29d0894d:/src/cpython# zcat /proc/config.gz  | grep CONFIG_CROSS_MEMORY_ATTACH# CONFIG_CROSS_MEMORY_ATTACH is not set

Diagnosis:
WhenCONFIG_CROSS_MEMORY_ATTACH is not set, the syscall handler forprocess_vm_readv (and alsoprocess_vm_writev) is not compiled into the kernel and so it returnsENOSYS aserrno.

If it's ok, I'd also like to / be happy to offer a PR to fix.
Specifically I'd go with the approach that I discovered someone contributed to py-spy, of falling back to the/proc/[pid]/mem file in the proc filesystem. I could even open such a PR pretty soon.

CPython versions tested on:

3.14, 3.15, CPython main branch

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.14bugs and security fixes3.15new features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp