Repository navigation
Conversation
Fixes oracle#1368. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Mathieu Dupuy <deronnax@gmail.com>
|
Thank you for your pull request and welcome to our community! To contribute, please sign the Oracle Contributor Agreement (OCA).
To sign the OCA, please create an Oracle account and sign the OCA in Oracle's Contributor Agreement Application. When signing the OCA, please provide your GitHub username. After signing the OCA and getting an OCA approval from Oracle, this PR will be automatically updated. If you are an Oracle employee, please make sure that you are a member of the main Oracle GitHub organization, and your membership in this organization is public. |
|
I signed the Oracle OCA, but so far it did not seem to work. |
|
Hi, @deronnax, I think the problem is that your email is not publicly visible in your github profile, so the bot cannot pair your signature with your profile |
|
Interesting. I made it publicly visible again, let's see. |
|
let's try to close and reopen, to see if it wakes the bot up. |
|
Hi @deronnax, I checked the internal API that the bot is using and it doesn't show a valid OCA for the email that is in your github profile. What email did you use in the OCA form? Is there some confirmation email or screenshot from the OCA app that you could forward to me to debug this further? |
|
Looks ok to me, I raised an internal ticket against the OCA service |
|
Thank you for signing the OCA. |
|
|
||
| private static void copyChunk(Node inliningTarget, PosixSupport posixSupport, Object handle, long from, long to, byte[] buffer, int n, PRaiseNode raiseNode) | ||
| throws PosixException { | ||
| int nread = posixSupport.mmapReadBytes(handle, from, buffer, n); |
There was a problem hiding this comment.
[P2] Support moves on write-only file mappings in the Java backend
With --python.PosixModuleBackend=java, a file mapping created with prot=mmap.PROT_WRITE passes the writability check, but copyChunk reads from a write-only channel and leaks NonReadableChannelException. The same move succeeds on CPython 3.13 on Linux x86-64. Give the Java backend a way to read the source bytes for move, and translate unsupported channel access into a Python exception.
| } | ||
| } | ||
|
|
||
| @Builtin(name = "move", minNumOfPositionalArgs = 4, parameterNames = {"$self", "dest", "src", "count"}) |
There was a problem hiding this comment.
[P2] Make all mmap.move parameters positional-only
m.move(dest=1, src=0, count=4) changes the mapping on GraalPy, whereas CPython 3.13 raises TypeError. Set numOfPositionalOnlyArgs = 4 so GraalPy rejects the keyword call before modifying the mapping.
| if (self.isClosed()) { | ||
| throw raiseNode.raise(inliningTarget, ValueError, MMAP_CLOSED_OR_INVALID); | ||
| } |
There was a problem hiding this comment.
[P3] Check for a closed mapping before converting move arguments
PythonQuaternaryClinicBuiltinNode converts the arguments before MoveNode.move checks self.isClosed(). On a closed map, m.move(None, 0, 1) therefore raises TypeError, while CPython 3.13 raises ValueError without inspecting the arguments. Check for closure before conversion and keep the check after conversion because __index__ can run Python code and close the mapping.
| int nread = posixSupport.mmapReadBytes(handle, from, buffer, n); | ||
| if (nread != n) { | ||
| throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.SystemError, MMAP_CHANGED_LENGTH); | ||
| } | ||
| posixSupport.mmapWriteBytes(handle, to, buffer, n); |
There was a problem hiding this comment.
[P3] Handle short transfers when moving bytes on Java-backed maps
A SeekableByteChannel can transfer fewer bytes than requested without reaching EOF or encountering an I/O failure. copyChunk treats a short read as a changed mapping length, and EmulatedPosixSupport.mmapWriteBytes treats a short write as EIO after partially updating the destination. Fill each chunk before writing it and retry short writes from the remaining buffer offset, with explicit handling for EOF and zero progress.
- Make all move() parameters positional-only. - Check that the mapping is open before converting the arguments, and again afterwards since __index__ can close it (like CPython 3.13). - Java POSIX backend: open writable mappings for reading as well, so that move() works on PROT_WRITE-only mappings, and translate channel access errors into OSError. - Java POSIX backend: handle short reads and writes on mmap channels, make AnonymousMap advance its position, and raise EIO properly when a write makes no progress. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Mathieu Dupuy <deronnax@gmail.com>

Fixes #1368.
mmap.mmapwas missing themove(dest, src, count)method.Changes
movebuiltin inMMapBuiltins, mirroring CPython'smmap_move_method:ValueError("mmap closed or invalid")on a closed map,TypeError("mmap can't modify a readonly memory map.")on anACCESS_READmap,ValueError("source, destination, or count out of range")for negative or out-of-bounds arguments.PosixSupport.mmapReadBytes/mmapWriteBytes: the copy goes through a 64 KiB buffer, chunk by chunk, backwards whendest > src, so overlapping ranges are handled.tests/test_mmap.py: the reproducer from the issue, error cases, chunked overlapping copies in both directions, and a read-only map.test.test_mmap.MmapTests.test_movefrom CPython is now tagged as passing on all platforms.Validation
b'aabcdf', like CPython.mx python-jvmbuild:mx graalpytest graalpython/com.oracle.graal.python.test/src/tests/test_mmap.py: 12 passed, 2 skipped (the Windows-only ones).mx graalpytest --tagged graalpython/lib-python/3/test/test_mmap.py: 28 passed, includingtest_move.python-unittest-gateand the tagged tests pass on linux-amd64. Note:python-svm-build-gate-linux-amd64currently fails upstream too, onmx python-check-call-host-inlining(host-inlining.txtnot found, see the CI of [GR-81685] Improvements of GetAttribute operation: new quickenings & revisit cache limits. #1369). To get past it, I disabled that check on a separate CI-only branch.🤖 Generated with Claude Code