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 2021/09/01 12:55:17 UTC

[GitHub] [arrow] lidavidm commented on a change in pull request #11041: ARROW-13812: [C++] Fix Valgrind error in Grouper.BooleanKey test

lidavidm commented on a change in pull request #11041:
URL: https://github.com/apache/arrow/pull/11041#discussion_r700184494



##########
File path: cpp/src/arrow/compute/exec/key_encode.cc
##########
@@ -427,11 +427,19 @@ void KeyEncoder::EncoderInteger::Decode(uint32_t start_row, uint32_t num_rows,
     row_base += offset_within_row;
     uint8_t* col_base = col_prep.mutable_data(1);
     switch (col_prep.metadata().fixed_length) {
-      case 1:
+      case 1: {
         for (uint32_t i = 0; i < num_rows; ++i) {
           col_base[i] = row_base[i * row_size];
         }
+        // For booleans, we pack 8 bytes at a time, and the buffer we're
+        // writing to here may not be fully initialized - so make sure a
+        // multiple of 8 bytes are initialized to avoid Valgrind errors. The
+        // temp buffer is sized to num_rows uint16_t values, so there's more
+        // than enough space here.
+        uint32_t remainder = 8 - (num_rows % 8);

Review comment:
       It should be OK (there's a typo here, it's uint32_t values so the temporary buffer is actually overallocated by a factor of 4x). But I've adjusted it anyways.




-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org