Skip to content

test_perf_profiler fails under Windows Subsystem for Linux #134986

Open
@emmatyping

Description

@emmatyping

Bug report

The culprit is that for some reason calling perf from the WSL raises a PermissionError, rather than FileNotFoundError or CalledProcessError when perf is not available.

Example output:

$ which perf # not present
$ ./python -m test test_perf_profiler -v
== CPython 3.15.0a0 (heads/main:3704171415c, May 31 2025, 12:20:03) [Clang 20.1.6 (++20250528122018+47addd4540b4-1~exp1~20250528002033.124)]
== Linux-6.6.87.1-microsoft-standard-WSL2-x86_64-with-glibc2.39 little-endian
== Python build: debug
== cwd: /home/emma/cpython/build/test_python_worker_7822æ
== CPU count: 32
== encodings: locale=UTF-8 FS=utf-8
== resources: all test resources are disabled, use -u option to unskip tests

Using random seed: 1838771651
0:00:00 load avg: 0.65 Run 1 test sequentially in a single process
0:00:00 load avg: 0.65 [1/1] test_perf_profiler
test test_perf_profiler crashed -- Traceback (most recent call last):
  File "/home/emma/cpython/Lib/test/libregrtest/single.py", line 210, in _runtest_env_changed_exc
    _load_run_test(result, runtests)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "/home/emma/cpython/Lib/test/libregrtest/single.py", line 155, in _load_run_test
    test_mod = importlib.import_module(module_name)
  File "/home/emma/cpython/Lib/importlib/__init__.py", line 88, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1398, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1371, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1342, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 938, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 762, in exec_module
  File "<frozen importlib._bootstrap>", line 491, in _call_with_frames_removed
  File "/home/emma/cpython/Lib/test/test_perf_profiler.py", line 522, in <module>
    _is_perf_version_at_least(6, 6), "perf command may not work due to a perf bug"
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/emma/cpython/Lib/test/test_perf_profiler.py", line 510, in _is_perf_version_at_least
    output = subprocess.check_output(["perf", "--version"], text=True)
  File "/home/emma/cpython/Lib/subprocess.py", line 472, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
           ~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
               **kwargs).stdout
               ^^^^^^^^^
  File "/home/emma/cpython/Lib/subprocess.py", line 554, in run
    with Popen(*popenargs, **kwargs) as process:
         ~~~~~^^^^^^^^^^^^^^^^^^^^^^
  File "/home/emma/cpython/Lib/subprocess.py", line 1038, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                        pass_fds, cwd, env,
                        ^^^^^^^^^^^^^^^^^^^
    ...<5 lines>...
                        gid, gids, uid, umask,
                        ^^^^^^^^^^^^^^^^^^^^^^
                        start_new_session, process_group)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/emma/cpython/Lib/subprocess.py", line 1970, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: 'perf'

0:00:00 load avg: 0.65 [1/1/1] test_perf_profiler failed (uncaught exception)

== Tests result: FAILURE ==

1 test failed:
    test_perf_profiler

Total duration: 270 ms
Total tests: run=0
Total test files: run=1/1 failed=1
Result: FAILURE

Linked PRs

Metadata

Metadata

Assignees

Labels

3.13bugs and security fixes3.14bugs and security fixes3.15new features, bugs and security fixestestsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions