facebookincubator / velox

A C++ vectorized database acceleration library aimed to optimizing query engines and data processing systems.
https://velox-lib.io/
Apache License 2.0
3.28k stars 1.09k forks source link

Presto function inverse_beta_cdf has potential infinite loop #9435

Open kgpai opened 2 months ago

kgpai commented 2 months ago

Description

Discovered via fuzzer runs, for potential values of a,b and p its possible for inverse_beta_cdf to potentially take a very long time doing calculating boost::math::quantile. One such set of values is : invBetaCDF(1.14934e+09, 1.59161e+74, 0.546686).

Error Reproduction

Adding following test in ProbabilityTest.h hangs:

TEST_F(ProbabilityTest, invBetaCDF) {
  const auto invBetaCDF = [&](std::optional<double> a,
                              std::optional<double> b,
                              std::optional<double> p) {
    return evaluateOnce<double>("inverse_beta_cdf(c0, c1, c2)", a, b, p);
  };

  EXPECT_EQ(1.0, invBetaCDF(1.14934e+09, 1.59161e+74, 0.546686));

Relevant logs

No response

kgpai commented 2 months ago

This seems to happen for boost 1.77 and I havent seen this with 1.84

kgpai commented 2 months ago

This is fixed here : https://github.com/boostorg/math/pull/1007/files by @yuhta (Thanks ! )