viliam-durina opened a new issue, #15730:
URL: https://github.com/apache/lucene/issues/15730

   ### Description
   
   The absolute read methods in `RandomAccessInput` should read from the given 
position, and not use or modify the input's position. However 
`MemorySegmentIndexInput`'s absolute `read` methods modify the input's position 
if the read happens at the segment boundary, because if the value can't be read 
from a single segment, the implementation falls back to seek + relative read.
   
   The following test reproduces it:
   ```java
   public class TestMemorySegmentIndexInput extends LuceneTestCase {
   
     public void testPositionNotModifiedAtBoundary() throws IOException {
       try (Arena arena = Arena.ofConfined()) {
         MemorySegment seg1 = arena.allocate(16);
         MemorySegment seg2 = arena.allocate(16);
         try (MemorySegmentIndexInput input = 
MemorySegmentIndexInput.newInstance("", arena,
             new MemorySegment[] {seg1, seg2}, 32, 4, false, null)) {
           input.readInt(4);
           assertEquals(0, input.getFilePointer());
           input.readInt(14);
           assertEquals(0, input.getFilePointer()); // this fails, position is 
now 18
         }
       }
     }
   }
   ```
   
   Perhaps it's not an actual issue, I don't know if Lucene combines relative 
and absolute reads anywhere and relies on the position not being changed by the 
absolute read, and even if it does, multiple segments are used if the file is 
larger than 16GB, so it's very unlikely. But it should be fixed anyway I think, 
because the root cause will be very hard to figure out should it happen.
   
   ### Version and environment details
   
   _No response_


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to