Jim Apple has uploaded this change for review. (
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
---
M be/src/exec/parquet/parquet-metadata-utils.cc
M be/src/util/ubsan.h
2 files changed, 54 insertions(+), 6 deletions(-)
git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/80/12280/1
--
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: newchange
Gerrit-Change-Id: Iecdf301065da8f091a274e7a0585a11fcc79da7d
Gerrit-Change-Number: 12280
Gerrit-PatchSet: 1
Gerrit-Owner: Jim Apple <[email protected]>