Xuanwo opened a new pull request, #8755: URL: https://github.com/apache/opendal/pull/8755
# Which issue does this PR close? None. Found during maintenance of the OCaml binding. # Rationale for this change `Operator.write` and `Operator.Writer.write` accepted `&'static [u8]` borrowed directly from an OCaml `bytes` value and passed it to core without copying. `Buffer::from(&'static [u8])` is zero-copy, and services or writers may retain that buffer after the call. Mutating the OCaml bytes then changes already-written data; letting the GC move or collect them leaves a dangling pointer. `Reader.pread` also converted the caller's buffer size into an exact range `offset..offset + size`. A buffer larger than the remaining bytes made the bounded-range completeness check fail with `reader got too little data`, and the addition could overflow. # What changes are included in this PR? - Copy `bytes` into an owned buffer in `blocking_write` and `writer_write` before passing data to core. - Implement `reader_pread` through an unbounded read that stops at EOF, so short reads return the available tail and reads at or beyond EOF return `0` without range overflow. - Make `blocking_create_dir` return `true` on success, matching its existing OCaml `(bool, string) result` signature. - Add OCaml tests for mutating caller buffers after `Operator.write` and between `Writer.write` calls, including `Gc.compact ()`, plus short reads and EOF reads. All new tests fail on the previous implementation. # Are there any user-facing changes? `Reader.pread` now succeeds with a short read instead of returning an error when the buffer extends past EOF. `Operator.create_dir` now returns `Ok true` on success instead of `Ok false`; the OCaml signature is unchanged. # Breaking changes # AI Usage Statement - Harness: pi coding agent - Model: group/deepseek - Effort: max - Role: Implemented the FFI buffer ownership and reader range fixes, added the OCaml regression tests, and ran the validation. The human author remains responsible for the change. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
