yugabyte / yugabyte-db

YugabyteDB - the cloud native distributed SQL database for mission-critical applications.
https://www.yugabyte.com
Other
8.99k stars 1.07k forks source link

ASAN:undefined-behavior issue in QLTestSelectedExpr_TestCastDecimal #1241

Closed OlegLoginov closed 5 years ago

OlegLoginov commented 5 years ago

1181 I 7.880555 20474 ql-test-base.h:136 Got result. Return type = 2 1182 src/yb/util/bfql/bfunc_convert.h:95:11: runtime error: 5e+308 is outside the range of representable values of type 'float' 1183 #0 0x7fb80ba39b82 in yb::Status yb::bfql::SetNumericResult<yb::Status ()(float, yb::QLValue), yb::QLValue, yb::QLValue>(yb::Status ()(float, yb::QLValue), yb::QLValue, yb::DataType, yb::QLValue) /net/centos-gcp-cloud-jenkins-slave-ad4/share/jenkins/workspace/yugabyte-centos-master-clang-asan/build/asan-clang-dynamic-enterprise-ninja/../../src/yb/util/bfql/bfunc_convert.h:95:11 1184 #1 0x7fb80ba37d98 in yb::Status yb::bfql::ConvertToNumeric<yb::QLValue, yb::QLValue, yb::Result ()(yb::Slice), yb::Status ()(float, yb::QLValue)>(yb::QLValue, yb::QLValue, yb::DataType const&, yb::Result ()(yb::Slice), yb::Status ()(float, yb::QLValue)) /net/centos-gcp-cloud-jenkins-slave-ad4/share/jenkins/workspace/yugabyte-centos-master-clang-asan/build/asan-clang-dynamic-enterprise-ninja/../../src/yb/util/bfql/bfunc_convert.h:1300:12 1185 #2 0x7fb80ba37bcf in yb::Status yb::bfql::ConvertToFloat<yb::QLValue, yb::QLValue>(yb::QLValue, yb::QLValue) /net/centos-gcp-cloud-jenkins-slave-ad4/share/jenkins/workspace/yugabyte-centos-master-clang-asan/build/asan-clang-dynamic-enterprise-ninja/../../src/yb/util/bfql/bfunc_convert.h:1330:10 1186 #3 0x7fb80b9da639 in yb::Status yb::bfql::OPERATOR_ConvertToFloat_134::ExecRefAndRaw<yb::QLValue, yb::QLValue>(std::1::vector<yb::QLValue, std::1::allocator >, yb::QLValue) /net/centos-gcp-cloud-jenkins-slave-ad4/share/jenkins/workspace/yugabyte-centos-master-clang-asan/build/asan-clang-dynamic-enterprise-ninja/src/yb/util/bfql/gen_operator.h:3800:12 1187 #4 0x7fb80ba3fe28 in decltype(std::1::forward<yb::Status (*&)(std::1::vector<yb::QLValue, std::1::allocator >, yb::QLValue)>(fp)(std::1::forward<std::1::vector<yb::QLValue, std::1::allocator >>(fp0), std::__1::forward<yb::QLValue>(fp0))) std::1::invoke<yb::Status (&)(std::1::vector<yb::QLValue, std::1::allocator >, yb::QLValue), std::1::vector<yb::QLValue, std::1::allocator >, yb::QLValue>(yb::Status (&)(std::1::vector<yb::QLValue, std::1::allocator >, yb::QLValue), std::1::vector<yb::QLValue, std::1::allocator >&&, yb::QLValue&&) /n/jenkins/thirdparty/yugabyte-thirdparty-2019-02-28T08_28_04/thirdparty/installed/asan/libcxx/include/c++/v1/type_traits:4345:1 1188 #5 0x7fb80ba3fe28 in yb::Status std::1::invoke_void_return_wrapper::call<yb::Status (*&)(std::1::vector<yb::QLValue, std::1::allocator >, yb::QLValue), std::1::vector<yb::QLValue, std::1::allocator >, yb::QLValue>(yb::Status (*&)(std::1::vector<yb::QLValue, std::1::allocator >, yb::QLValue), std::1::vector<yb::QLValue, std::1::allocator >&&, yb::QLValue&&) $YB_THIRDPARTY_DIR/installed/asan/libcxx/include/c++/v1/functional_base:318 1189 #6 0x7fb80ba3fd0d in std::1::function::func<yb::Status (*)(std::1::vector<yb::QLValue, std::1::allocator >, yb::QLValue), std::1::allocator<yb::Status ()(std::1::vector<yb::QLValue, std::1::allocator >, yb::QLValue)>, yb::Status (std::1::vector<yb::QLValue, std::1::allocator >, yb::QLValue)>::operator()(std::1::vector<yb::QLValue, std::1::allocator >&&, yb::QLValue&&) $YB_THIRDPARTY_DIR/installed/asan/libcxx/include/c++/v1/functional:1562:12 1190 #7 0x7fb80ba3f7b7 in std::1::function<yb::Status (std::1::vector<yb::QLValue, std::__1::allocator >, yb::QLValue)>::operator()(std::1::vector<yb::QLValue, std::1::allocator >, yb::QLValue) const $YB_THIRDPARTY_DIR/installed/asan/libcxx/include/c++/v1/functional:1913:12 1191 #8 0x7fb80b9bba05 in yb::bfql::BFExecApi<yb::QLValue, yb::QLValue, std::1::vector, std::1::allocator>::ExecQLOpcode(yb::bfql::BFOpcode, std::1::vector<yb::QLValue, std::1::allocator >, yb::QLValue) /net/centos-gcp-cloud-jenkins-slave-ad4/share/jenkins/workspace/yugabyte-centos-master-clang-asan/build/asan-clang-dynamic-enterprise-ninja/../../src/yb/util/bfql/bfql.h:317:16 1192 #9 0x7fb80b9baeb5 in yb::QLBfunc::Exec(yb::bfql::BFOpcode, std::1::vector<yb::QLValue, std::1::allocator >, yb::QLValue) /net/centos-gcp-cloud-jenkins-slave-ad4/share/jenkins/workspace/yugabyte-centos-master-clang-asan/build/asan-clang-dynamic-enterprise-ninja/../../src/yb/common/ql_bfunc.cc:42:10 1193 #10 0x7fb80ba6a4f6 in yb::QLExprExecutor::EvalBFCall(yb::QLBCallPB const&, yb::QLTableRow const&, yb::QLValue) /net/centos-gcp-cloud-jenkins-slave-ad4/share/jenkins/workspace/yugabyte-centos-master-clang-asan/build/asan-clang-dynamic-enterprise-ninja/../../src/yb/common/ql_expr.cc:123:10 1194 #11 0x7fb80ba694a5 in yb::QLExprExecutor::EvalExpr(yb::QLExpressionPB const&, yb::QLTableRow const&, yb::QLValue) /net/centos-gcp-cloud-jenkins-slave-ad4/share/jenkins/workspace/yugabyte-centos-master-clang-asan/build/asan-clang-dynamic-enterprise-ninja/../../src/yb/common/ql_expr.cc 1195 #12 0x7fb814f95550 in yb::docdb::QLReadOperation::PopulateResultSet(yb::QLTableRow const&, yb::QLResultSet) /net/centos-gcp-cloud-jenkins-slave-ad4/share/jenkins/workspace/yugabyte-centos-master-clang-asan/build/asan-clang-dynamic-enterprise-ninja/../../src/yb/docdb/cql_operation.cc:1204:5 1196 #13 0x7fb814f942f2 in yb::docdb::QLReadOperation::AddRowToResult(std::1::unique_ptr<yb::common::QLScanSpec, std::1::default_delete > const&, yb::QLTableRow const&, unsigned long, unsigned long, yb::QLResultSet, int, unsigned long*) /net/centos-gcp-cloud-jenkins-slave-ad4/share/jenkins/workspace/yugabyte-centos-master-clang-asan/build/asan-clang-dynamic-enterprise-ninja/../../src/yb/docdb/cql_operation.cc:1251:11 1197 #14 0x7fb814f928c5 in yb::docdb::QLReadOperation::Execute(yb::common::YQLStorageIf const&, std::1::chrono::time_point<yb::CoarseMonoClock, std::1::chrono::duration<long long, std::1::ratio<1l, 1000000000l> > >, yb::ReadHybridTime const&, yb::Schema const&, yb::Schema const&, yb::QLResultSet, yb::HybridTime) /net/centos-gcp-cloud-jenkins-slave-ad4/share/jenkins/workspace/yugabyte-centos-master-clang-asan/build/asan-clang-dynamic-enterprise-ninja/../../src/yb/docdb/cql_operation.cc:1156:9 1198 #15 0x7fb8164d4a7c in yb::tablet::AbstractTablet::HandleQLReadRequest(std::__1::chrono::time_point<yb::CoarseMonoClock, std::1::chrono::duration<long long, std::1::ratio<1l, 1000000000l> > >, yb::ReadHybridTime const&, yb::QLReadRequestPB const&, boost::optional const&, yb::tablet::QLReadRequestResult*) /net/centos-gcp-cloud-jenkins-slave-ad4/share/jenkins/workspace/yugabyte-centos-master-clang-asan/build/asan-clang-dynamic-enterprise-ninja/../../src/yb/tablet/abstract_tablet.cc:51:27 1199 #16 0x7fb8164eedb8 in yb::tablet::Tablet::HandleQLReadRequest(std::__1::chrono::time_point<yb::CoarseMonoClock, std::1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >, yb::ReadHybridTime const&, yb::QLReadRequestPB const&, yb::TransactionMetadataPB const&, yb::tablet::QLReadRequestResult) /net/centos-gcp-cloud-jenkins-slave-ad4/share/jenkins/workspace/yugabyte-centos-master-clang-asan/build/asan-clang-dynamic-enterprise-ninja/../../src/yb/tablet/tablet.cc:884:26 1200 #17 0x7fb8171de4e8 in yb::tserver::TabletServiceImpl::DoRead(yb::tserver::ReadContext) /net/centos-gcp-cloud-jenkins-slave-ad4/share/jenkins/workspace/yugabyte-centos-master-clang-asan/build/asan-clang-dynamic-enterprise-ninja/../../src/yb/tserver/tablet_service.cc:1279:7 1201 #18 0x7fb8171dc63f in yb::tserver::TabletServiceImpl::CompleteRead(yb::tserver::ReadContext) /net/centos-gcp-cloud-jenkins-slave-ad4/share/jenkins/workspace/yugabyte-centos-master-clang-asan/build/asan-clang-dynamic-enterprise-ninja/../../src/yb/tserver/tablet_service.cc:1151:19 1202 #19 0x7fb8171db0c7 in yb::tserver::TabletServiceImpl::Read(yb::tserver::ReadRequestPB const, yb::tserver::ReadResponsePB, yb::rpc::RpcContext) /net/centos-gcp-cloud-jenkins-slave-ad4/share/jenkins/workspace/yugabyte-centos-master-clang-asan/build/asan-clang-dynamic-enterprise-ninja/../../src/yb/tserver/tablet_service.cc:1142:3 1203 #20 0x7fb80f3784eb in yb::tserver::TabletServerServiceIf::Handle(std::1::shared_ptr) /net/centos-gcp-cloud-jenkins-slave-ad4/share/jenkins/workspace/yugabyte-centos-master-clang-asan/build/asan-clang-dynamic-enterprise-ninja/src/yb/tserver/tserver_service.service.cc:153:7 1204 #21 0x7fb809c60e84 in yb::rpc::ServicePoolImpl::Handle(std::1::shared_ptr) /net/centos-gcp-cloud-jenkins-slave-ad4/share/jenkins/workspace/yugabyte-centos-master-clang-asan/build/asan-clang-dynamic-enterprise-ninja/../../src/yb/rpc/service_pool.cc:214:15 1205 #22 0x7fb809c5c910 in yb::rpc::(anonymous namespace)::InboundCallTask::Run() /net/centos-gcp-cloud-jenkins-slave-ad4/share/jenkins/workspace/yugabyte-centos-master-clang-asan/build/asan-clang-dynamic-enterprise-ninja/../../src/yb/rpc/service_pool.cc:252:10 1206 #23 0x7fb809c77f81 in yb::rpc::(anonymous namespace)::Worker::Execute() /net/centos-gcp-cloud-jenkins-slave-ad4/share/jenkins/workspace/yugabyte-centos-master-clang-asan/build/asan-clang-dynamic-enterprise-ninja/../../src/yb/rpc/thread_pool.cc:101:15 1207 #24 0x7fb806a45c46 in yb::Thread::SuperviseThread(void) /net/centos-gcp-cloud-jenkins-slave-ad4/share/jenkins/workspace/yugabyte-centos-master-clang-asan/build/asan-clang-dynamic-enterprise-ninja/../../src/yb/util/thread.cc:660:3 1208 #25 0x7fb800326693 in start_thread /tmp/glibc-20181130-26094-cs1x60/glibc-2.23/nptl/pthread_create.c:333 1209 #26 0x7fb7ffe5141c in __clone /tmp/glibc-20181130-26094-cs1x60/glibc-2.23/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:109 1210
1211 SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../../src/yb/util/bfql/bfunc_convert.h:95:11 in

OlegLoginov commented 5 years ago

Root cause: floating point values casting with overflow. (Sanitizer: float-cast-overflow) For example:

double d = 1.E+100;
float f= d;

The result is Inf, and that's correct. So we decided with @mbautin to suppress the message.

OlegLoginov commented 5 years ago

Fixed by: https://github.com/YugaByte/yugabyte-db/commit/adc1eac7ce9f324a5ab30cc456c1bcc98e0db3b3