zacharymorn commented on pull request #2052: URL: https://github.com/apache/lucene-solr/pull/2052#issuecomment-748804203
> This may also happen on other operating systems. It depends on if the buffer is already aligned when you call alignSlice(). If it is not aligned (seems to happen 100% of the time on windows), then the returned slice is ALWAYS smaller than original size. If you read the example code by OpenJDK developers and the tests: You need to overallocate (`finalSize + blockSize - 1`) and then get the aligned slice. Yeah makes sense. I did see and use `Math.addExact(blockSize, blockSize - 1)` before referencing https://bugs.openjdk.java.net/browse/JDK-8189192, but the dots never connected for me that this was done for the purpose of handling unaligned buffer, and that it needs to be adapted to `finalSize + blockSize - 1` here. And for some reasons this misalignment never happens on Mac so the test is always passing for me. Glad that this bug gets caught! ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org