You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by ta...@apache.org on 2019/06/03 16:35:54 UTC

[impala] 02/06: IMPALA-5031: memcpy requires two non-null arguments

This is an automated email from the ASF dual-hosted git repository.

tarmstrong pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git

commit d8a0c60b88329bd89c9d80265d1292168bf7603e
Author: Jim Apple <jb...@apache.org>
AuthorDate: Fri May 24 18:17:46 2019 -0700

    IMPALA-5031: memcpy requires two non-null arguments
    
    Counterintuitively, even passing 0 as the third argument of memcpy
    does not avoid undefined behavior. This occurred during an end-to-end
    test. The interesting part of the backtrace is:
    
        util/dict-encoding.h:451:20: runtime error: null pointer passed
           as argument 2, which is declared to never be null
        /usr/include/string.h:43:45: note: nonnull attribute specified
           here
        #0 DictEncoder<StringValue>::AddToTable(StringValue const&,
           unsigned short*) util/dict-encoding.h:451:3
        #1 DictEncoder<StringValue>::Put(StringValue const&)
           util/dict-encoding.h:422:10
        #2 HdfsParquetTableWriter::ColumnWriter<StringValue>::
           ProcessValue(void*, long*)
           exec/parquet/hdfs-parquet-table-writer.cc:436:38
        #3 HdfsParquetTableWriter::BaseColumnWriter::AppendRow(TupleRow*)
           exec/parquet/hdfs-parquet-table-writer.cc:662:9
        #4 HdfsParquetTableWriter::AppendRows(RowBatch*,
           vector<int> const&, bool*)
           exec/parquet/hdfs-parquet-table-writer.cc:1192:60
        #5 HdfsTableSink::WriteRowsToPartition(RuntimeState*, RowBatch*,
           pair<unique_ptr<OutputPartition>, vector<int>>*)
           exec/hdfs-table-sink.cc:253:71
        #6 HdfsTableSink::Send(RuntimeState*, RowBatch*)
           exec/hdfs-table-sink.cc:588:45
    
    Change-Id: I2e8e57c34c2848f0dc7dbf32892cc6e86df63506
    Reviewed-on: http://gerrit.cloudera.org:8080/13434
    Reviewed-by: Impala Public Jenkins <im...@cloudera.com>
    Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
 be/src/util/dict-encoding.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/be/src/util/dict-encoding.h b/be/src/util/dict-encoding.h
index fa52275..c7174f6 100644
--- a/be/src/util/dict-encoding.h
+++ b/be/src/util/dict-encoding.h
@@ -30,6 +30,7 @@
 #include "util/bit-util.h"
 #include "util/mem-util.h"
 #include "util/rle-encoding.h"
+#include "util/ubsan.h"
 
 namespace impala {
 
@@ -448,7 +449,7 @@ template<>
 inline int DictEncoder<StringValue>::AddToTable(const StringValue& value,
     NodeIndex* bucket) {
   char* ptr_copy = reinterpret_cast<char*>(pool_->Allocate(value.len));
-  memcpy(ptr_copy, value.ptr, value.len);
+  Ubsan::MemCpy(ptr_copy, value.ptr, value.len);
   StringValue sv(ptr_copy, value.len);
   Node node(sv, *bucket);
   ConsumeBytes(sizeof(node));