You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2020/12/09 07:29:00 UTC

[GitHub] [arrow] kiszk opened a new pull request #8876: ARROW-10860: [Java] Avoid integer overflow for generated classes in Vector

kiszk opened a new pull request #8876:
URL: https://github.com/apache/arrow/pull/8876


   For the current implementation in the templates for Vector, `int * int` multiplication is used to calculate a buffer offset. The result may be larger than Integer.MAX_VALUE, which will lead to integer overflow and unexpected behaviors.
   
   This PR is like a follow-up of #8721.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [arrow] kiszk commented on a change in pull request #8876: ARROW-10860: [Java] Avoid integer overflow for generated classes in Vector

Posted by GitBox <gi...@apache.org>.
kiszk commented on a change in pull request #8876:
URL: https://github.com/apache/arrow/pull/8876#discussion_r539178117



##########
File path: java/vector/src/main/codegen/templates/UnionListWriter.java
##########
@@ -194,13 +194,13 @@ public void endList() {
   @Override
   public void startList() {
     vector.startNewValue(idx());
-    writer.setPosition(vector.getOffsetBuffer().getInt((idx() + 1) * OFFSET_WIDTH));
+    writer.setPosition(vector.getOffsetBuffer().getInt(((long) idx() + 1L) * OFFSET_WIDTH));

Review comment:
       Sure, you are right. I just followed the style around here. I removed the explicit cast for this and others.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [arrow] kiszk commented on pull request #8876: ARROW-10860: [Java] Avoid integer overflow for generated classes in Vector

Posted by GitBox <gi...@apache.org>.
kiszk commented on pull request #8876:
URL: https://github.com/apache/arrow/pull/8876#issuecomment-741609422


   cc @liyafan82 


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [arrow] liyafan82 commented on pull request #8876: ARROW-10860: [Java] Avoid integer overflow for generated classes in Vector

Posted by GitBox <gi...@apache.org>.
liyafan82 commented on pull request #8876:
URL: https://github.com/apache/arrow/pull/8876#issuecomment-741651999


   @kiszk Nice catch. Thank you!
   The PR generally looks good, with some minor comments. 
   
   Maybe we can add some integration test to avoid such problems. However, this can be left as a future work. 


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [arrow] liyafan82 commented on a change in pull request #8876: ARROW-10860: [Java] Avoid integer overflow for generated classes in Vector

Posted by GitBox <gi...@apache.org>.
liyafan82 commented on a change in pull request #8876:
URL: https://github.com/apache/arrow/pull/8876#discussion_r539146792



##########
File path: java/vector/src/main/codegen/templates/UnionListWriter.java
##########
@@ -194,13 +194,13 @@ public void endList() {
   @Override
   public void startList() {
     vector.startNewValue(idx());
-    writer.setPosition(vector.getOffsetBuffer().getInt((idx() + 1) * OFFSET_WIDTH));
+    writer.setPosition(vector.getOffsetBuffer().getInt(((long) idx() + 1L) * OFFSET_WIDTH));

Review comment:
       nit: By adding 1L, the result of `idx()` is automatically cast to a long, so the explicit cast can be avoided?




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [arrow] github-actions[bot] commented on pull request #8876: ARROW-10860: [Java] Avoid integer overflow for generated classes in Vector

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #8876:
URL: https://github.com/apache/arrow/pull/8876#issuecomment-741589578


   https://issues.apache.org/jira/browse/ARROW-10860


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [arrow] liyafan82 closed pull request #8876: ARROW-10860: [Java] Avoid integer overflow for generated classes in Vector

Posted by GitBox <gi...@apache.org>.
liyafan82 closed pull request #8876:
URL: https://github.com/apache/arrow/pull/8876


   


----------------------------------------------------------------
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:
users@infra.apache.org