You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by tm...@apache.org on 2019/02/12 04:06:59 UTC
[impala] 05/05: IMPALA-5031: signed overflow is undefined behavior
This is an automated email from the ASF dual-hosted git repository.
tmarshall pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git
commit 6fc05a6f7385bf21de1c01a3071b9a91efc85b07
Author: Jim Apple <jb...@apache.org>
AuthorDate: Sat Feb 9 21:17:51 2019 -0800
IMPALA-5031: signed overflow is undefined behavior
Tis patch fixes a signed overflow in the test
StringToDecimal.LargeDecimals. The interesting part of the backtrace
is:
util/string-parser.h:397:14: runtime error: signed integer overflow:
0x4b3b4ca85a86c47a098a223fffffffff * 10 cannot be represented in
type '__int128'
#0 void StringParser::ApplyExponent<__int128>(int, int,
signed char, __int128*, int*, int*) util/string-parser.h:397:14
#1 DecimalValue<__int128> StringParser::StringToDecimal<__int128>
(char const*, int, int, int, bool, StringParser::ParseResult*)
util/string-parser.h:221:5
#2 void VerifyParse<__int128>(string const&, int, int, bool,
DecimalValue<__int128> const&, StringParser::ParseResult)
runtime/decimal-test.cc:53:25
#3 void VerifyParse<__int128>(string const&, int, int,
DecimalValue<__int128> const&, StringParser::ParseResult)
runtime/decimal-test.cc:65:3
#4 StringToDecimal_LargeDecimals_Test::TestBody()
runtime/decimal-test.cc:443:3
Change-Id: Ifb4effa291e1e4dac62b84251c74c483d99b06e7
Reviewed-on: http://gerrit.cloudera.org:8080/12426
Reviewed-by: Jim Apple <jb...@apache.org>
Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
be/src/util/string-parser.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/be/src/util/string-parser.h b/be/src/util/string-parser.h
index 606e5b8..7f3a191 100644
--- a/be/src/util/string-parser.h
+++ b/be/src/util/string-parser.h
@@ -394,7 +394,8 @@ class StringParser {
if (exponent > digits_after_dot_count) {
// Ex: 0.1e3 (which at this point would have precision == 1 and scale == 1), the
// scale must be set to 0 and the value set to 100 which means a precision of 3.
- *value *= DecimalUtil::GetScaleMultiplier<T>(exponent - digits_after_dot_count);
+ *value = ArithmeticUtil::AsUnsigned<std::multiplies>(
+ *value, DecimalUtil::GetScaleMultiplier<T>(exponent - digits_after_dot_count));
*precision = total_digits_count + (exponent - digits_after_dot_count);
*scale = 0;
} else {