-
-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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
gh-127076: Ignore memory mmap in FileIO testing #127088
Conversation
`mmap`, `munmap`, and `mprotect` are used by CPython for memory management, which may occur in the middle of the FileIO tests. The system calls can also be used with files, so `strace` includes them in its `%file` and `%desc` filters. Filter out the `mmap` system calls related to memory allocation for the file tests. Currently FileIO doesn't do `mmap` at all, so didn't add code to track from `mmap` through `munmap` since it wouldn't be used. For now if an `mmap` on a fd happens, the call will be included (which may cause test to fail), and at that time support for tracking the address throug `munmap` could be added.
Validated by modifying # "open, read, close" file using different common patterns.
check_readall(
"open builtin with default options",
f"""
f = open('{TESTFN}')
a = "123" * 100000
f.read()
f.close()
"""
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I can confirm the test passes under musl now.
Lib/test/support/strace_helper.py
Outdated
# mmap can operate on a fd or "MAP_ANON" which gives a block of memory. | ||
# Ignore the "MAP_ANON" ones. | ||
if call.syscall == "mmap" and "MAP_ANON" in call.args[3]: | ||
return False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to return True if the syscall should be filtered, and False otherwise? In short, replace if _filter(call)
with if not _filter(call)
.
Lib/test/support/strace_helper.py
Outdated
of memory. Use this function to filter out the memory related calls from | ||
other calls.""" | ||
|
||
def _filter(call): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this function at the module level? Maybe rename it to _filter_memory_call().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can move, my thought initially was "Track the address mmap returns through munmap" and the set/dictionary of "known addresses" would be in the outer scope, but I don't think mmap
in io
is likely (there's the mmap
module if it's better for a particular use case)
mmap
,munmap
, andmprotect
are used by CPython for memory management which may occur in the middle of the FileIO tests. The system calls can also be used with files, sostrace
includes them in its%file
and%desc
filters.Filter out the
mmap
system calls related to memory allocation for the file tests. Currently FileIO doesn't dommap
at all, so didn't add code to track frommmap
throughmunmap
since it wouldn't be used. For now if anmmap
on a fd happens, the call will be included (which may cause tests to fail), and at that time support for tracking the address throughmunmap
could be added.cc: @mgorny this should fix the glibc and musl Gentoo general failures outside sandbox
cc: @brandtbucher This re-enables for PYTHON_JIT, and filters out the
mmap
calls used for memory management