python / python/cpython

Tachyon: Permission error on subprocesses are not propagated back to the user

Open
#155,031 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stdlib topic-profiling type-bug
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Bug report

Bug description:

Running python -m profiling.sampling run --subprocesses <...> on some code that spawns subprocesses will ignore any PermissionError thrown in the child processes when doing a attach to the process, since stderr is forwarded to /dev/null, and the process exits with error code 0 (my mistake, it does exit with exit code 1, just the call is in the helper function). This causes confusion as the only user-visible effect is that the subprocesses sampling data files are not created.

This can happen when the user / python executable / kernel doesn't have the CAP_SYS_PTRACE capability, so the run subcommand works fine, but any attach will fail, which is what happens with the child processes.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs
  • gh-155032

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Lib/profiling/sampling/_child_monitor.py at the subprocess attach path and Lib/profiling/sampling/main.py at the run command entry point. Reproduce the command on Linux without CAP_SYS_PTRACE, then verify that a child-process PermissionError is visible to the user rather than only appearing as missing sampling data. PR gh-155032 is already linked to this issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.