Skip to content

gh-149619 Fix _remote_debugging permissions error on Linux#150012

Open
ivonastojanovic wants to merge 1 commit into
python:mainfrom
ivonastojanovic:fix_permission_error
Open

gh-149619 Fix _remote_debugging permissions error on Linux#150012
ivonastojanovic wants to merge 1 commit into
python:mainfrom
ivonastojanovic:fix_permission_error

Conversation

@ivonastojanovic
Copy link
Copy Markdown
Contributor

@ivonastojanovic ivonastojanovic commented May 18, 2026

When running profiling on Linux without sudo, attempts to read process memory would fail with the misleading error 'Failed to find the PyRuntime section in process on Linux platform'.

The actual issue is a permissions error because profiling was not run with sudo. We were clearing the exception on Linux when trying to read memory, instead, we should bubble up the permissions error and show it properly.

@ivonastojanovic ivonastojanovic changed the title gh-149619 Fix _remote_debugging permissions error on Linux gh-149619 Fix _remote_debugging permissions error on Linux May 18, 2026
When running profiling on Linux without sudo, attempts to read
process memory would fail with the misleading error 'Failed to find
the PyRuntime section in process <pid> on Linux platform'.

The actual issue is a permissions error because profiling was not
run with sudo. We were clearing the exception on Linux when trying
to read memory, instead, we should bubble up the permissions error
and show it properly.
@ivonastojanovic
Copy link
Copy Markdown
Contributor Author

cc @maurycy

Copy link
Copy Markdown
Contributor

@maurycy maurycy left a comment

Choose a reason for hiding this comment

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

@ivonastojanovic

I cannot click "Approve" but it's great. 🎉 The issue is gone. 🌬️

Two side comments!

My hunch is that there's still something subtle around error propagation (likely: EACCES propagation) but I cannot catch any!

I spent some time thinking on how to test it. What do you think about:

@unittest.skipUnless(
    sys.platform == "linux"
    and Path("/proc/sys/kernel/yama/ptrace_scope").exists()
    and int(Path("/proc/sys/kernel/yama/ptrace_scope").read_text()) >= 1,
    "needs Linux with ptrace_scope >= 1"
)

This feels so fragile!

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.

2 participants