Skip to content

test_fileio fails if strace version is too old #133741

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pablogsal opened this issue May 9, 2025 · 9 comments
Closed

test_fileio fails if strace version is too old #133741

pablogsal opened this issue May 9, 2025 · 9 comments
Labels
tests Tests in the Lib/test dir topic-IO type-bug An unexpected behavior, bug, or error

Comments

@pablogsal
Copy link
Member

pablogsal commented May 9, 2025

Bug report

Bug description:

Many failures in the test if the strace version doesn't support some of the options:

25-05-08T15:38:14.817Z] ======================================================================
[2025-05-08T15:38:14.817Z] FAIL: test_syscalls_read (test.test_fileio.CAutoFileTests.test_syscalls_read) (name='open builtin with default options')
[2025-05-08T15:38:14.817Z] Check set of system calls during common I/O patterns
[2025-05-08T15:38:14.817Z] ----------------------------------------------------------------------
[2025-05-08T15:38:14.817Z] Traceback (most recent call last):
[2025-05-08T15:38:14.817Z]   File "/bb/jenkins_work/python/workspace/python_python3.14-debian_PR-1/distro/refroot/amd64/opt/bb/lib64/python3.14/test/test_fileio.py", line 381, in check_readall
[2025-05-08T15:38:14.817Z]     syscalls = strace_helper.get_events(code, _strace_flags,
[2025-05-08T15:38:14.817Z]                                           prelude=prelude,
[2025-05-08T15:38:14.817Z]                                           cleanup=cleanup)
[2025-05-08T15:38:14.817Z]   File "/bb/jenkins_work/python/workspace/python_python3.14-debian_PR-1/distro/refroot/amd64/opt/bb/lib64/python3.14/test/support/strace_helper.py", line 162, in get_events
[2025-05-08T15:38:14.817Z]     trace = strace_python(to_run, strace_flags)
[2025-05-08T15:38:14.817Z]   File "/bb/jenkins_work/python/workspace/python_python3.14-debian_PR-1/distro/refroot/amd64/opt/bb/lib64/python3.14/test/support/strace_helper.py", line 122, in strace_python
[2025-05-08T15:38:14.817Z]     res.fail(cmd_line)
[2025-05-08T15:38:14.817Z]     ~~~~~~~~^^^^^^^^^^
[2025-05-08T15:38:14.817Z]   File "/bb/jenkins_work/python/workspace/python_python3.14-debian_PR-1/distro/refroot/amd64/opt/bb/lib64/python3.14/test/support/script_helper.py", line 80, in fail
[2025-05-08T15:38:14.817Z]     raise AssertionError(f"Process return code is {exitcode}\n"
[2025-05-08T15:38:14.817Z]     ...<10 lines>...
[2025-05-08T15:38:14.817Z]                          f"---")
[2025-05-08T15:38:14.817Z] AssertionError: Process return code is 1
[2025-05-08T15:38:14.817Z] command line: ['/usr/bin/strace', '--trace=%file,%desc', '/bb/jenkins_work/python/workspace/python_python3.14-debian_PR-1/distro/refroot/amd64/opt/bb/bin/python3.14', '-X', 'faulthandler', '-I', '-c', '\nprint("MARK prelude", flush=True)\n\nprint("MARK code", flush=True)\n\nf = open(\'@test_123835_tmpæ\')\nf.read()\nf.close()\n\nprint("MARK cleanup", flush=True)\n\nprint("MARK __shutdown", flush=True)\n']
[2025-05-08T15:38:14.817Z] 
[2025-05-08T15:38:14.817Z] stdout:
[2025-05-08T15:38:14.817Z] ---
[2025-05-08T15:38:14.817Z] 
[2025-05-08T15:38:14.817Z] ---
[2025-05-08T15:38:14.817Z] 
[2025-05-08T15:38:14.817Z] stderr:
[2025-05-08T15:38:14.817Z] ---
[2025-05-08T15:38:14.817Z] /usr/bin/strace: invalid option -- '-'
[2025-05-08T15:38:14.817Z] Try '/usr/bin/strace -h' for more information.
[2025-05-08T15:38:14.817Z] ---

CPython versions tested on:

3.14

Operating systems tested on:

Linux

Linked PRs

@pablogsal pablogsal added the type-bug An unexpected behavior, bug, or error label May 9, 2025
@pablogsal
Copy link
Member Author

CC @vstinner @cmaloney

@pablogsal
Copy link
Member Author

CC @hauntsaninja

@picnixz picnixz added tests Tests in the Lib/test dir topic-IO labels May 9, 2025
@vstinner
Copy link
Member

vstinner commented May 9, 2025

What is your strace version?

Which option is rejected? Is it the --trace=%file,%desc option?

@pablogsal
Copy link
Member Author

(refroot)$ strace -V
strace -- version 4.12
(refroot)$ strace --trace=%file,%desc
strace: invalid option -- '-'
Try 'strace -h' for more information.
(refroot)$ strace -h
usage: strace [-CdffhiqrtttTvVwxxy] [-I n] [-e expr]...
              [-a column] [-o file] [-s strsize] [-P path]...
              -p pid... / [-D] [-E var=val]... [-u username] PROG [ARGS]
   or: strace -c[dfw] [-I n] [-e expr]... [-O overhead] [-S sortby]
              -p pid... / [-D] [-E var=val]... [-u username] PROG [ARGS]

Output format:
  -a column      alignment COLUMN for printing syscall results (default 40)
  -i             print instruction pointer at time of syscall
  -o file        send trace output to FILE instead of stderr
  -q             suppress messages about attaching, detaching, etc.
  -r             print relative timestamp
  -s strsize     limit length of print strings to STRSIZE chars (default 32)
  -t             print absolute timestamp
  -tt            print absolute timestamp with usecs
  -T             print time spent in each syscall
  -x             print non-ascii strings in hex
  -xx            print all strings in hex
  -y             print paths associated with file descriptor arguments
  -yy            print protocol specific information associated with socket file descriptors

Statistics:
  -c             count time, calls, and errors for each syscall and report summary
  -C             like -c but also print regular output
  -O overhead    set overhead for tracing syscalls to OVERHEAD usecs
  -S sortby      sort syscall counts by: time, calls, name, nothing (default time)
  -w             summarise syscall latency (default is system time)

Filtering:
  -e expr        a qualifying expression: option=[!]all or option=[!]val1[,val2]...
     options:    trace, abbrev, verbose, raw, signal, read, write
  -P path        trace accesses to path

Tracing:
  -b execve      detach on execve syscall
  -D             run tracer process as a detached grandchild, not as parent
  -f             follow forks
  -ff            follow forks with output into separate files
  -I interruptible
     1:          no signals are blocked
     2:          fatal signals are blocked while decoding syscall (default)
     3:          fatal signals are always blocked (default if '-o FILE PROG')
     4:          fatal signals and SIGTSTP (^Z) are always blocked
                 (useful to make 'strace -o FILE PROG' not stop on ^Z)

Startup:
  -E var         remove var from the environment for command
  -E var=val     put var=val in the environment for command
  -p pid         trace process with process id PID, may be repeated
  -u username    run command as username handling setuid and/or setgid

Miscellaneous:
  -d             enable debug output to stderr
  -v             verbose mode: print unabbreviated argv, stat, termios, etc. args
  -h             print help message
  -V             print version

vstinner added a commit to vstinner/cpython that referenced this issue May 9, 2025
Need strace 5.5 or newer for the --trace option.
@vstinner
Copy link
Member

vstinner commented May 9, 2025

(refroot)$ strace -V
strace -- version 4.12

The --trace option was added to strace 5.5.

Can you try my fix #133763 ?

@pablogsal
Copy link
Member Author

(refroot)$ strace -V
strace -- version 4.12

The --trace option was added to strace 5.5.

Can you try my fix #133763 ?

(refroot)$ python3.14 -m test test_fileio -v
== CPython 3.14.0b1 (main, May 8 2025, 10:45:27) [Clang 20.1.0 ]
== Linux-3.10.0-957.35.2.el7.x86_64-x86_64-with-glibc2.17 little-endian
== Python build: release shared
== cwd: /bb/data/tmp/test_python_worker_50669æ
== CPU count: 15 (process) / 16 (system)
== encodings: locale=UTF-8 FS=utf-8
== resources: all test resources are disabled, use -u option to unskip tests

Using random seed: 4196976212
0:00:00 load avg: 4.96 Run 1 test sequentially in a single process
0:00:00 load avg: 4.96 [1/1] test_fileio
test_fileio skipped -- need strace 5.5 or newer, found strace 4.12
0:00:00 load avg: 4.96 [1/1] test_fileio skipped

== Tests result: SUCCESS ==

1 test skipped:
    test_fileio

Total duration: 66 ms
Total tests: run=0
Total test files: run=1/1 skipped=1
Result: SUCCESS

This skips the entre test, is that expected?

vstinner added a commit to vstinner/cpython that referenced this issue May 9, 2025
The --trace option needs strace 5.5 or newer.
@vstinner
Copy link
Member

vstinner commented May 9, 2025

This skips the entre test, is that expected?

Hum, no, my change doesn't work as expected.

Can you please try the simpler fix: #133766 ?

vstinner added a commit that referenced this issue May 9, 2025
The --trace option needs strace 5.5 or newer.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 9, 2025
…3766)

The --trace option needs strace 5.5 or newer.
(cherry picked from commit 6708628)

Co-authored-by: Victor Stinner <vstinner@python.org>
@vstinner vstinner closed this as completed May 9, 2025
@vstinner
Copy link
Member

vstinner commented May 9, 2025

Thanks for the report. A fix was merged into the main branch, the backport to 3.14 will follow.

vstinner added a commit that referenced this issue May 9, 2025
…#133774)

gh-133741: Fix _can_strace(): check --trace option (GH-133766)

The --trace option needs strace 5.5 or newer.
(cherry picked from commit 6708628)

Co-authored-by: Victor Stinner <vstinner@python.org>
@hauntsaninja
Copy link
Contributor

Thanks for fixing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir topic-IO type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

4 participants