This is an automated email from the ASF dual-hosted git repository. joemcdonnell pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/impala.git
The following commit(s) were added to refs/heads/master by this push: new 7a2e80c Revert "IMPALA-9781: Fix GCC 7 unaligned 128-bit loads / stores" 7a2e80c is described below commit 7a2e80cf602b8c13d935cfc06a2a55a3c48f8d0b Author: Joe McDonnell <joemcdonn...@cloudera.com> AuthorDate: Fri May 29 12:32:01 2020 -0700 Revert "IMPALA-9781: Fix GCC 7 unaligned 128-bit loads / stores" The change in decimal-util.h introduced undefined behavior. See IMPALA-9800. This reverts commit 227da84c3757eb857008e7b82aad622ed959eb84. Change-Id: Id2b2e43c478a220ff545fdbca712e47905c8d22b Reviewed-on: http://gerrit.cloudera.org:8080/16006 Reviewed-by: Joe McDonnell <joemcdonn...@cloudera.com> Reviewed-by: Tim Armstrong <tarmstr...@cloudera.com> Tested-by: Impala Public Jenkins <impala-public-jenk...@cloudera.com> --- be/src/exprs/slot-ref.cc | 5 +---- be/src/util/decimal-util.h | 3 +-- be/src/util/dict-encoding.h | 5 ++--- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/be/src/exprs/slot-ref.cc b/be/src/exprs/slot-ref.cc index 661c7ef..634a989 100644 --- a/be/src/exprs/slot-ref.cc +++ b/be/src/exprs/slot-ref.cc @@ -422,10 +422,7 @@ DecimalVal SlotRef::GetDecimalValInterpreted( case 8: return DecimalVal(*reinterpret_cast<int64_t*>(t->GetSlot(slot_offset_))); case 16: - // Avoid an unaligned load by using memcpy - __int128_t val; - memcpy(&val, t->GetSlot(slot_offset_), sizeof(val)); - return DecimalVal(val); + return DecimalVal(*reinterpret_cast<int128_t*>(t->GetSlot(slot_offset_))); default: DCHECK(false); return DecimalVal::null(); diff --git a/be/src/util/decimal-util.h b/be/src/util/decimal-util.h index 4ddfe23..f505ecc 100644 --- a/be/src/util/decimal-util.h +++ b/be/src/util/decimal-util.h @@ -128,8 +128,7 @@ class DecimalUtil { const uint8_t* buffer, int fixed_len_size, T* v) { DCHECK_GT(fixed_len_size, 0); DCHECK_LE(fixed_len_size, sizeof(T)); - // Avoid an unaligned store by using memset - memset(v, 0, sizeof(T)); + *v = 0; // We need to sign extend val. For example, if the original value was // -1, the original bytes were -1,-1,-1,-1. If we only wrote out 1 byte, after // the encode step above, val would contain (-1, 0, 0, 0). We need to sign diff --git a/be/src/util/dict-encoding.h b/be/src/util/dict-encoding.h index e6e01bc..f440332 100644 --- a/be/src/util/dict-encoding.h +++ b/be/src/util/dict-encoding.h @@ -346,11 +346,10 @@ class DictDecoder : public DictDecoderBase { virtual int num_entries() const { return dict_.size(); } virtual void GetValue(int index, void* buffer) { + T* val_ptr = reinterpret_cast<T*>(buffer); DCHECK_GE(index, 0); DCHECK_LT(index, dict_.size()); - // Avoid an unaligned store by using memcpy - T val = dict_[index]; - memcpy(buffer, reinterpret_cast<const void*>(&val), sizeof(T)); + *val_ptr = dict_[index]; } /// Returns the next value. Returns false if the data is invalid.