Skip to content

profiling.sampling doesn't work under venv on Windows #148932

Closed

Description

@sergey-miryanov

Bug report

Bug description:

Running the following command inside a virtual environment triggers this error on Windows:
Failed to find the PyRuntime section in process 29072 on Windows platform

python -m profiling.sampling run --subprocesses -m test test_gc

I suspect this happens because virtual environments use shims to launch the original interpreter. Since the shim itself isn't a Python process, that's why profiling.sampling fails.

We can work around this: if --subprocesses option specified then we should proceed with profiling as long as at least one child process is a Python process.

cc @pablogsal

CPython versions tested on:

CPython main branch

Operating systems tested on:

Windows

Linked PRs

Activity

  1. added
    type-bug
    extension-modules
    on Apr 23, 2026
  2. pablogsal commented on Apr 23, 2026

    @pablogsal
    Member

    I think at the very least we should improve the error message if we are sure enough that's the case. Could you make a PR for that @sergey-miryanov ?

  3. sergey-miryanov commented on Apr 24, 2026

    @sergey-miryanov
    ContributorAuthor

    Yes, will try to do.

  4. added a commit that references this issue on May 2, 2026
  5. added 2 commits that reference this issue on May 24, 2026
  6. added a commit that references this issue on Jun 8, 2026
  7. added a commit that references this issue on Jun 8, 2026
  8. added a commit that references this issue on Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulestopic-profilingtype-bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions