Skip to content

Unable to attach pdb remote debugger on MacOS #137033

@anze3db

Description

@anze3db

Bug report

Bug description:

When I try to attach a remote debugger on MacOS with:

python3.14 -m pdb -p 58653

I get the following error:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Library/Frameworks/Python.framework/Versions/3.14/lib/python3.14/pdb.py", line 3610, in <module>
    pdb.main()
    ~~~~~~~~^^
  File "/Library/Frameworks/Python.framework/Versions/3.14/lib/python3.14/pdb.py", line 3541, in main
    attach(opts.pid, opts.commands)
    ~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.14/lib/python3.14/pdb.py", line 3425, in attach
    sys.remote_exec(pid, connect_script.name)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: Cannot get task port for PID 58653 (kern_return_t: 5). This typically requires running as root or having the 'com.apple.system-task-ports' entitlement

The same thing happens also with sudo:

sudo python3.14 -m pdb -p 58653

or the root user:

sudo su
sh-3.2# python3.14 -m pdb -p 58653

I am able to get it to work by running the same command on Linux in Docker:

root@40505a05971f:/data# python -m pdb -p 13
> /data/remote_debugging.py(8)<module>()
-> time.sleep(1)

This is on MacOS Sequoia Version 15.5 and I'm using Python 3.14.0rc1 (b4 had the same issue though).

The release notes don't mention anything about this being a Linux only feature so I'm not sure if I'm doing something wrong or if this is an actual bug.

The script that I'm trying to attach to:

import os
import time

print(os.getpid())
counter = 1
while True:
    counter += 1
    time.sleep(1)

CPython versions tested on:

3.14

Operating systems tested on:

macOS

Metadata

Metadata

Assignees

Labels

OS-mactype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions