Impala Public Jenkins has submitted this change and it was merged. ( 
http://gerrit.cloudera.org:8080/12280 )

Change subject: IMPALA-5031: out-of-range enum values are undefined behavior
......................................................................

IMPALA-5031: out-of-range enum values are undefined behavior

This patch adds a utility, Ubsan::EnumToInt(), that can take a pointer
to an enumeration value and return its integral value without invoking
undefined behavior. This is not as simple as "int i = *pe" because (a)
the underlying integral type might not be int, and (b) if pe points to
a value outside of the range of the enum as defined in the standard
(section dcl.enum), then dereferencing it is undefined behavior.

This fixes errors found in the end-to-end tests:

    exec/parquet/parquet-metadata-utils.cc:215:26: runtime error: load
      of value 5000, which is not a valid value for type
     'CompressionCodec::type'
    exec/parquet/parquet-metadata-utils.cc:216:26: runtime error: load
      of value 5000, which is not a valid value for type
      'CompressionCodec::type'
    exec/parquet/parquet-metadata-utils.cc:217:26: runtime error: load
      of value 5000, which is not a valid value for type
      'CompressionCodec::type'
    exec/parquet/parquet-metadata-utils.cc:219:47: runtime error: load
      of value 5000, which is not a valid value for type
      'CompressionCodec::type'
    exec/parquet/parquet-metadata-utils.cc:501:22: runtime error: load
      of value 4294967278, which is not a valid value for type
      'FieldRepetitionType::type'
    exec/parquet/parquet-metadata-utils.cc:503:29: runtime error: load
      of value 4294967278, which is not a valid value for type
      'FieldRepetitionType::type'

Change-Id: Iecdf301065da8f091a274e7a0585a11fcc79da7d
Reviewed-on: http://gerrit.cloudera.org:8080/12280
Reviewed-by: Impala Public Jenkins <impala-public-jenk...@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenk...@cloudera.com>
---
M be/src/exec/parquet/parquet-metadata-utils.cc
M be/src/util/ubsan.h
2 files changed, 54 insertions(+), 6 deletions(-)

Approvals:
  Impala Public Jenkins: Looks good to me, approved; Verified

--
To view, visit http://gerrit.cloudera.org:8080/12280
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Iecdf301065da8f091a274e7a0585a11fcc79da7d
Gerrit-Change-Number: 12280
Gerrit-PatchSet: 3
Gerrit-Owner: Jim Apple <jbapple-imp...@apache.org>
Gerrit-Reviewer: Impala Public Jenkins <impala-public-jenk...@cloudera.com>
Gerrit-Reviewer: Jim Apple <jbapple-imp...@apache.org>
Gerrit-Reviewer: Tim Armstrong <tarmstr...@cloudera.com>

Reply via email to