Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fromUnixtime() crashes if it gets a NaN or Inf #67

Closed
pedroerp opened this issue Aug 18, 2021 · 3 comments
Closed

fromUnixtime() crashes if it gets a NaN or Inf #67

pedroerp opened this issue Aug 18, 2021 · 3 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@pedroerp
Copy link
Contributor

pedroerp commented Aug 18, 2021

functions/common/DateTimeImpl.h:29 crashes UBSAN if the double passed as a parameter is NaN or Inf:

===
Stack trace example:

buck-out/dev/gen/aab7ed39/f4d/functions/common/f4d_functions_common#header-mode-symlink-tree-with-header-map,headers/f4d/functions/common/DateTimeImpl.h:33:20: runtime error: -nan is outside the range of representable values of type 'long'
    #0 0x7fdc359711db in fromUnixtime f4d/functions/common/DateTimeImpl.h:33         
    #1 0x7fdc359711db in call f4d/functions/common/DateTimeFunctions.h:32           
    #2 0x7fdc359711db in call f4d/core/ScalarFunction.h:254                                                                    
    #3 0x7fdc359711db in doApplyNotNull<1, double, 0> f4d/expression/VectorFunctionAdapter.h:297
    #4 0x7fdc359711db in doApplyNotNull<0, const facebook::f4d::exec::VectorReader<double, void>, 0> f4d/expression/VectorFunctionAdapter.h:287
    #5 0x7fdc359711db in _ZZNK8facebook3f4d4exec13VectorAdapterINS0_4core9UDFHolderINS0_9functions17udf_from_unixtime3udfINS1_10VectorExecEEES8_NS0_9TimestampEJdEEEE7iterateIJNS1_12VectorReaderIdvEEEEEvRNSC_12ApplyContextEbDpRKT_ENKUlTyT_E_clIiEEDaSM_ f4d
/expression/VectorFunctionAdapter.h:135                                                                                        
    #6 0x7fdc359729c8 in _ZZN8facebook3f4d4bits10forEachBitIZNKS0_4exec13VectorAdapterINS0_4core9UDFHolderINS0_9functions17udf_from_unixtime3udfINS3_10VectorExecEEESA_NS0_9TimestampEJdEEEE7iterateIJNS3_12VectorReaderIdvEEEEEvRNSE_12ApplyContextEbDpRKT_EUl
TyT_E_EEvPKmiibSO_ENKUlimE_clEim f4d/common/base/BitUtil.h:347                                                                 
    #7 0x7fdc35972425 in _ZN8facebook3f4d4bits11forEachWordIZNS1_10forEachBitIZNKS0_4exec13VectorAdapterINS0_4core9UDFHolderINS0_9functions17udf_from_unixtime3udfINS4_10VectorExecEEESB_NS0_9TimestampEJdEEEE7iterateIJNS4_12VectorReaderIdvEEEEEvRNSF_12Apply
ContextEbDpRKT_EUlTyT_E_EEvPKmiibSP_EUlimE_ZNS3_ISQ_EEvSS_iibSP_EUliE_EEviiSP_T0_ f4d/common/base/BitUtil.h:186
    #8 0x7fdc35971fdd in _ZN8facebook3f4d4bits10forEachBitIZNKS0_4exec13VectorAdapterINS0_4core9UDFHolderINS0_9functions17udf_from_unixtime3udfINS3_10VectorExecEEESA_NS0_9TimestampEJdEEEE7iterateIJNS3_12VectorReaderIdvEEEEEvRNSE_12ApplyContextEbDpRKT_EUlT
yT_E_EEvPKmiibSO_ f4d/common/base/BitUtil.h:338                                                                                
    #9 0x7fdc35971a83 in _ZN8facebook3f4d4bits13forEachSetBitIZNKS0_4exec13VectorAdapterINS0_4core9UDFHolderINS0_9functions17udf_from_unixtime3udfINS3_10VectorExecEEESA_NS0_9TimestampEJdEEEE7iterateIJNS3_12VectorReaderIdvEEEEEvRNSE_12ApplyContextEbDpRKT_E
UlTyT_E_EEvPKmiiSO_ f4d/common/base/BitUtil.h:367
    #10 0x7fdc359707c5 in _ZNK8facebook3f4d17SelectivityVector15applyToSelectedIZNKS0_4exec13VectorAdapterINS0_4core9UDFHolderINS0_9functions17udf_from_unixtime3udfINS3_10VectorExecEEESA_NS0_9TimestampEJdEEEE7iterateIJNS3_12VectorReaderIdvEEEEEvRNSE_12App
lyContextEbDpRKT_EUlTyT_E_EEvSO_ f4d/vector/SelectivityVector.h:361
    #11 0x7fdc359701f4 in void facebook::f4d::exec::VectorAdapter<facebook::f4d::core::UDFHolder<facebook::f4d::functions::udf_from_unixtime::udf<facebook::f4d::exec::VectorExec>, facebook::f4d::exec::VectorExec, facebook::f4d::Timestamp, double> >::itera
te<facebook::f4d::exec::VectorReader<double, void> >(facebook::f4d::exec::VectorAdapter<facebook::f4d::core::UDFHolder<facebook::f4d::functions::udf_from_unixtime::udf<facebook::f4d::exec::VectorExec>, facebook::f4d::exec::VectorExec, facebook::f4d::Times
tamp, double> >::ApplyContext&, bool, facebook::f4d::exec::VectorReader<double, void> const&) const f4d/expression/VectorFunctionAdapter.h:133
    #12 0x7fdc3596fd92 in void facebook::f4d::exec::VectorAdapter<facebook::f4d::core::UDFHolder<facebook::f4d::functions::udf_from_unixtime::udf<facebook::f4d::exec::VectorExec>, facebook::f4d::exec::VectorExec, facebook::f4d::Timestamp, double> >::unpac
k<1, facebook::f4d::exec::VectorReader<double, void>, 0>(facebook::f4d::exec::VectorAdapter<facebook::f4d::core::UDFHolder<facebook::f4d::functions::udf_from_unixtime::udf<facebook::f4d::exec::VectorExec>, facebook::f4d::exec::VectorExec, facebook::f4d::T
imestamp, double> >::ApplyContext&, bool, facebook::f4d::exec::DecodedArgs const&, facebook::f4d::exec::VectorReader<double, void> const&) const f4d/expression/VectorFunctionAdapter.h:115
    #13 0x7fdc3596e6c6 in void facebook::f4d::exec::VectorAdapter<facebook::f4d::core::UDFHolder<facebook::f4d::functions::udf_from_unixtime::udf<facebook::f4d::exec::VectorExec>, facebook::f4d::exec::VectorExec, facebook::f4d::Timestamp, double> >::unpac
k<0, 0>(facebook::f4d::exec::VectorAdapter<facebook::f4d::core::UDFHolder<facebook::f4d::functions::udf_from_unixtime::udf<facebook::f4d::exec::VectorExec>, facebook::f4d::exec::VectorExec, facebook::f4d::Timestamp, double> >::ApplyContext&, bool, faceboo
k::f4d::exec::DecodedArgs const&) const f4d/expression/VectorFunctionAdapter.h:96
    #14 0x7fdc3596cdcd in facebook::f4d::exec::VectorAdapter<facebook::f4d::core::UDFHolder<facebook::f4d::functions::udf_from_unixtime::udf<facebook::f4d::exec::VectorExec>, facebook::f4d::exec::VectorExec, facebook::f4d::Timestamp, double> >::apply(face
book::f4d::SelectivityVector const&, std::vector<std::shared_ptr<facebook::f4d::BaseVector>, std::allocator<std::shared_ptr<facebook::f4d::BaseVector> > >&, facebook::f4d::exec::Expr*, facebook::f4d::exec::EvalCtx*, std::shared_ptr<facebook::f4d::BaseVect
or>*) const f4d/expression/VectorFunctionAdapter.h:69
    #15 0x7fdc34efa692 in facebook::f4d::exec::Expr::applyVectorFunction(facebook::f4d::SelectivityVector const&, facebook::f4d::exec::EvalCtx*, std::shared_ptr<facebook::f4d::BaseVector>*) f4d/expression/Expr.cpp:1026
    #16 0x7fdc34ef89d9 in facebook::f4d::exec::Expr::applyFunction(facebook::f4d::SelectivityVector const&, facebook::f4d::SelectivityVector const&, facebook::f4d::exec::EvalCtx*, std::shared_ptr<facebook::f4d::BaseVector>*) f4d/expression/Expr.cpp:1009
    #17 0x7fdc34eebc48 in facebook::f4d::exec::Expr::evalAll(facebook::f4d::SelectivityVector const&, facebook::f4d::exec::EvalCtx*, std::shared_ptr<facebook::f4d::BaseVector>*) f4d/expression/Expr.cpp:862
    #18 0x7fdc34ef4703 in facebook::f4d::exec::Expr::evalWithNulls(facebook::f4d::SelectivityVector const&, facebook::f4d::exec::EvalCtx*, std::shared_ptr<facebook::f4d::BaseVector>*) f4d/expression/Expr.cpp:654
    #19 0x7fdc34eed1cf in facebook::f4d::exec::Expr::evalEncodings(facebook::f4d::SelectivityVector const&, facebook::f4d::exec::EvalCtx*, std::shared_ptr<facebook::f4d::BaseVector>*) f4d/expression/Expr.cpp:580
    #20 0x7fdc34eeab83 in facebook::f4d::exec::Expr::eval(facebook::f4d::SelectivityVector const&, facebook::f4d::exec::EvalCtx*, std::shared_ptr<facebook::f4d::BaseVector>*) f4d/expression/Expr.cpp:251
    #21 0x7fdc34eeb6cc in facebook::f4d::exec::Expr::evalAll(facebook::f4d::SelectivityVector const&, facebook::f4d::exec::EvalCtx*, std::shared_ptr<facebook::f4d::BaseVector>*) f4d/expression/Expr.cpp:840
    #22 0x7fdc34ef4703 in facebook::f4d::exec::Expr::evalWithNulls(facebook::f4d::SelectivityVector const&, facebook::f4d::exec::EvalCtx*, std::shared_ptr<facebook::f4d::BaseVector>*) f4d/expression/Expr.cpp:654
    #23 0x7fdc34eed1cf in facebook::f4d::exec::Expr::evalEncodings(facebook::f4d::SelectivityVector const&, facebook::f4d::exec::EvalCtx*, std::shared_ptr<facebook::f4d::BaseVector>*) f4d/expression/Expr.cpp:580
    #24 0x7fdc34eeab83 in facebook::f4d::exec::Expr::eval(facebook::f4d::SelectivityVector const&, facebook::f4d::exec::EvalCtx*, std::shared_ptr<facebook::f4d::BaseVector>*) f4d/expression/Expr.cpp:251
    #25 0x7fdc34efcd6e in facebook::f4d::exec::ExprSet::eval(int, int, bool, facebook::f4d::SelectivityVector const&, facebook::f4d::exec::EvalCtx*, std::vector<std::shared_ptr<facebook::f4d::BaseVector>, std::allocator<std::shared_ptr<facebook::f4d::Base
Vector> > >*) f4d/expression/Expr.cpp:1114
    #26 0x2db31d in facebook::f4d::ExpressionExplorer::go() f4d/expression/tests/ExpressionExplorer.cpp:342
@majetideepak
Copy link
Collaborator

@pedroerp how do we reproduce this?

@pedroerp
Copy link
Contributor Author

pedroerp commented Sep 3, 2021

@majetideepak sorry, just saw this update. You can run expression fuzzer and at some point it will bump into this (or some other) issue. I was able to reproduce it today by running the following:

velox/expression/tests/velox_expression_fuzzer_main --seed 2919216839

just make sure you open expression/tests/ExpressionFuzzerMain.cpp and remove "fromUnixtime" from line 38 first. Also, you need to enable ubsan so it crashes the binary.

@pedroerp pedroerp added the good first issue Good for newcomers label Sep 3, 2021
@pedroerp pedroerp self-assigned this Sep 29, 2021
@pedroerp
Copy link
Contributor Author

This was fixed.

facebook-github-bot pushed a commit that referenced this issue Mar 3, 2022
Summary:
X-link: facebookincubator/hsthrift#67

Updating `googletest` from `1.8.0` to `1.10.0`

Reviewed By: mzlee, igorsugak, luciang, meyering, r-barnes

Differential Revision: D34351084

fbshipit-source-id: 939b3985ab63a06b6d511ec8711c2d5863bdfea8
shiyu-bytedance pushed a commit to shiyu-bytedance/velox-1 that referenced this issue Aug 18, 2022
Summary:
X-link: facebookincubator/hsthrift#67

Updating `googletest` from `1.8.0` to `1.10.0`

Reviewed By: mzlee, igorsugak, luciang, meyering, r-barnes

Differential Revision: D34351084

fbshipit-source-id: 939b3985ab63a06b6d511ec8711c2d5863bdfea8
zhouyuan pushed a commit to zhouyuan/velox that referenced this issue Jun 7, 2023
relative pr:

Check a fallback case in validation: using literal partition key in window function facebookincubator#148
Fix might_contain validate fallback and support struct literal facebookincubator#137
Implement datetime functions in velox/sparksql. facebookincubator#81
Parse options in SingularOrList correctly facebookincubator#48
Add SingularOrList support facebookincubator#45
Support if then in filter facebookincubator#74
Fix semi join output type and support existence join facebookincubator#67
Support decimal as partition column facebookincubator#167
Add the window support facebookincubator#61
Add expand operator facebookincubator#65
Support more cases of filter and its pushdown facebookincubator#14
Yohahaha pushed a commit to Yohahaha/velox that referenced this issue Jul 4, 2023
relative pr:

Check a fallback case in validation: using literal partition key in window function facebookincubator#148
Fix might_contain validate fallback and support struct literal facebookincubator#137
Implement datetime functions in velox/sparksql. facebookincubator#81
Parse options in SingularOrList correctly facebookincubator#48
Add SingularOrList support facebookincubator#45
Support if then in filter facebookincubator#74
Fix semi join output type and support existence join facebookincubator#67
Support decimal as partition column facebookincubator#167
Add the window support facebookincubator#61
Add expand operator facebookincubator#65
Support more cases of filter and its pushdown facebookincubator#14
chenxu14 pushed a commit to chenxu14/velox that referenced this issue Jul 5, 2023
relative pr:

Check a fallback case in validation: using literal partition key in window function facebookincubator#148
Fix might_contain validate fallback and support struct literal facebookincubator#137
Implement datetime functions in velox/sparksql. facebookincubator#81
Parse options in SingularOrList correctly facebookincubator#48
Add SingularOrList support facebookincubator#45
Support if then in filter facebookincubator#74
Fix semi join output type and support existence join facebookincubator#67
Support decimal as partition column facebookincubator#167
Add the window support facebookincubator#61
Add expand operator facebookincubator#65
Support more cases of filter and its pushdown facebookincubator#14
PHILO-HE pushed a commit to PHILO-HE/velox that referenced this issue Jul 17, 2023
relative pr:

Check a fallback case in validation: using literal partition key in window function facebookincubator#148
Fix might_contain validate fallback and support struct literal facebookincubator#137
Implement datetime functions in velox/sparksql. facebookincubator#81
Parse options in SingularOrList correctly facebookincubator#48
Add SingularOrList support facebookincubator#45
Support if then in filter facebookincubator#74
Fix semi join output type and support existence join facebookincubator#67
Support decimal as partition column facebookincubator#167
Add the window support facebookincubator#61
Add expand operator facebookincubator#65
Support more cases of filter and its pushdown facebookincubator#14
rui-mo pushed a commit to rui-mo/velox that referenced this issue Jul 21, 2023
relative pr:

Check a fallback case in validation: using literal partition key in window function facebookincubator#148
Fix might_contain validate fallback and support struct literal facebookincubator#137
Implement datetime functions in velox/sparksql. facebookincubator#81
Parse options in SingularOrList correctly facebookincubator#48
Add SingularOrList support facebookincubator#45
Support if then in filter facebookincubator#74
Fix semi join output type and support existence join facebookincubator#67
Support decimal as partition column facebookincubator#167
Add the window support facebookincubator#61
Add expand operator facebookincubator#65
Support more cases of filter and its pushdown facebookincubator#14
rui-mo pushed a commit to rui-mo/velox that referenced this issue Jul 24, 2023
relative pr:

Check a fallback case in validation: using literal partition key in window function facebookincubator#148
Fix might_contain validate fallback and support struct literal facebookincubator#137
Implement datetime functions in velox/sparksql. facebookincubator#81
Parse options in SingularOrList correctly facebookincubator#48
Add SingularOrList support facebookincubator#45
Support if then in filter facebookincubator#74
Fix semi join output type and support existence join facebookincubator#67
Support decimal as partition column facebookincubator#167
Add the window support facebookincubator#61
Add expand operator facebookincubator#65
Support more cases of filter and its pushdown facebookincubator#14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants