Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-72621

Fix failed invariant when encoding Decimal128 with precision and min with more decimal points than precision

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 6.3.0-rc0
    • Affects Version/s: None
    • Component/s: Queryable Encryption
    • None
    • Fully Compatible
    • ALL
    • Hide

      The test case ASSERT_EIBB(5, "18446744073709551616", ".01", 1, 49) in  Double_Bounds_Precision results in the following invariant failure:

      {"t":{"$date":"2023-01-09T14:57:45.295Z"},"s":"F",  "c":"ASSERT",   "id":23079,   "ctx":"main","msg":"Invariant failure","attr":{"expr":"dec.round() == dec","file":"src/mongo/crypto/fle_crypto.cpp","line":3630}}
      {"t":{"$date":"2023-01-09T14:57:45.295Z"},"s":"F",  "c":"ASSERT",   "id":23080,   "ctx":"main","msg":"\n\n***aborting after invariant() failure\n\n"}
      {"t":{"$date":"2023-01-09T14:57:45.295Z"},"s":"F",  "c":"CONTROL",  "id":6384300, "ctx":"main","msg":"Writing fatal message","attr":{"message":"\n"}}
      {"t":{"$date":"2023-01-09T14:57:45.295Z"},"s":"F",  "c":"CONTROL",  "id":6384300, "ctx":"main","msg":"Writing fatal message","attr":{"message":"Got signal: 6 (Aborted).\n"}}
      {"t":{"$date":"2023-01-09T14:57:45.304Z"},"s":"I",  "c":"CONTROL",  "id":31380,   "ctx":"main","msg":"BACKTRACE","attr":{"bt":{"backtrace":[{"a":"7F12588668F9","b":"7F1258682000","o":"1E48F9","s":"_ZN5mongo18stack_trace_detail12_GLOBAL__N_117getStackTraceImplERKNS1_7OptionsE","C":"mongo::stack_trace_detail::(anonymous namespace)::getStackTraceImpl(mongo::stack_trace_detail::(anonymous namespace)::Options const&)","s+":"129"},{"a":"7F1258867920","b":"7F1258682000","o":"1E5920","s":"_ZN5mongo15printStackTraceEv","C":"mongo::printStackTrace()","s+":"30"},{"a":"7F1258862D2D","b":"7F1258682000","o":"1E0D2D","s":"abruptQuit","s+":"12D"},{"a":"7F12569F0980","b":"7F12569DE000","o":"12980","s":"funlockfile","s+":"50"},{"a":"7F125662BE87","b":"7F12565ED000","o":"3EE87","s":"gsignal","s+":"C7"},{"a":"7F125662D7F1","b":"7F12565ED000","o":"407F1","s":"abort","s+":"141"},{"a":"7F1258855E3B","b":"7F1258682000","o":"1D3E3B","s":"_ZN5mongo12_GLOBAL__N_19callAbortEv","C":"mongo::(anonymous namespace)::callAbort()","s+":"1B"},{"a":"7F1258855D0D","b":"7F1258682000","o":"1D3D0D","s":"_ZN5mongo15invariantFailedEPKcS1_j","C":"mongo::invariantFailed(char const*, char const*, unsigned int)","s+":"ED"},{"a":"7F1259190E3C","b":"7F125915A000","o":"36E3C","s":"_ZN5mongo22toInt128FromDecimal128ENS_10Decimal128E","C":"mongo::toInt128FromDecimal128(mongo::Decimal128)","s+":"21C"},{"a":"7F12591911F8","b":"7F125915A000","o":"371F8","s":"_ZN5mongo21getTypeInfoDecimal128ENS_10Decimal128EN5boost8optionalIS0_EES3_NS2_IjEE","C":"mongo::getTypeInfoDecimal128(mongo::Decimal128, boost::optional<mongo::Decimal128>, boost::optional<mongo::Decimal128>, boost::optional<unsigned int>)","s+":"318"},{"a":"557C523615A4","b":"557C5225D000","o":"1045A4","s":"_ZN5mongo62UnitTest_SuiteNameRangeTestTestNameDecimal128_Bounds_Precision7_doTestEv","C":"mongo::UnitTest_SuiteNameRangeTestTestNameDecimal128_Bounds_Precision::_doTest()","s+":"4A84"},{"a":"7F1259210F89","b":"7F12591E5000","o":"2BF89","s":"_ZN5mongo8unittest4Test3runEv","C":"mongo::unittest::Test::run()","s+":"19"},{"a":"557C5239BA7E","b":"557C5225D000","o":"13EA7E","s":"_ZZN5mongo8unittest4Test17RegistrationAgentINS_62UnitTest_SuiteNameRangeTestTestNameDecimal128_Bounds_PrecisionEEC1EPKNS0_8TestInfoEENKUlvE_clEv","C":"mongo::unittest::Test::RegistrationAgent<mongo::UnitTest_SuiteNameRangeTestTestNameDecimal128_Bounds_Precision>::RegistrationAgent(mongo::unittest::TestInfo const*)::{lambda()#1}::operator()() const","s+":"4E"},{"a":"7F125921282A","b":"7F12591E5000","o":"2D82A","s":"_ZN5mongo8unittest5Suite3runERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_i","C":"mongo::unittest::Suite::run(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)","s+":"42A"},{"a":"7F12592140D6","b":"7F12591E5000","o":"2F0D6","s":"_ZN5mongo8unittest5Suite3runERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS8_EERKS8_SE_i","C":"mongo::unittest::Suite::run(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)","s+":"606"},{"a":"7F125923C895","b":"7F1259237000","o":"5895","s":"main","s+":"E15"},{"a":"7F125660EC87","b":"7F12565ED000","o":"21C87","s":"__libc_start_main","s+":"E7"},{"a":"557C52301A8A","b":"557C5225D000","o":"A4A8A","s":"_start","s+":"2A"}],"processInfo":{"mongodbVersion":"unknown","gitVersion":"none","compiledModules":["unknown"],"uname":{"sysname":"Linux","release":"5.4.0-1085-aws","version":"#92~18.04.1-Ubuntu SMP Wed Aug 31 17:21:08 UTC 2022","machine":"x86_64"},"somap":[{"b":"557C5225D000","elfType":3,"buildId":"465A763F4D432B627410111E3B526D08BCEAD0DE"},{"b":"7F1259237000","path":"/home/ubuntu/mongo/build/install/bin/../lib/libunittest_main.so","elfType":3,"buildId":"499651BD0BF382F88709D18EDF39086B541D9BE7"},{"b":"7F12591E5000","path":"/home/ubuntu/mongo/build/install/bin/../lib/libunittest.so","elfType":3,"buildId":"947DCAFF87C10215EA72AB95C12D9159540A38E4"},{"b":"7F125915A000","path":"/home/ubuntu/mongo/build/install/bin/../lib/libfle_crypto.so","elfType":3,"buildId":"710E2BA20EDC3259CE4EDBE8253BB961D404FA2E"},{"b":"7F1258682000","path":"/home/ubuntu/mongo/build/install/bin/../lib/libbase.so","elfType":3,"buildId":"910FC70761C855A2191338C99E7AC5A7B309DE3C"},{"b":"7F12569DE000","path":"/lib/x86_64-linux-gnu/libpthread.so.0","elfType":3,"buildId":"8B60B9F8D9A27F2264A0D8E6C0768B3B02C29926"},{"b":"7F12565ED000","path":"/lib/x86_64-linux-gnu/libc.so.6","elfType":3,"buildId":"71F0F3074A929E519E85F6A5C03A7D1FD976BFE4"}]}}},"tags":[]}
      {"t":{"$date":"2023-01-09T14:57:45.304Z"},"s":"I",  "c":"CONTROL",  "id":31445,   "ctx":"main","msg":"Frame","attr":{"frame":{"a":"7F12588668F9","b":"7F1258682000","o":"1E48F9","s":"_ZN5mongo18stack_trace_detail12_GLOBAL__N_117getStackTraceImplERKNS1_7OptionsE","C":"mongo::stack_trace_detail::(anonymous namespace)::getStackTraceImpl(mongo::stack_trace_detail::(anonymous namespace)::Options const&)","s+":"129"}}}
      
      Show
      The test case ASSERT_EIBB(5, "18446744073709551616", ".01", 1, 49) in   Double_Bounds_Precision results in the following invariant failure: {"t":{"$date":"2023-01-09T14:57:45.295Z"},"s":"F", "c":"ASSERT", "id":23079, "ctx":"main","msg":"Invariant failure","attr":{"expr":"dec.round() == dec","file":"src/mongo/crypto/fle_crypto.cpp","line":3630}} {"t":{"$date":"2023-01-09T14:57:45.295Z"},"s":"F", "c":"ASSERT", "id":23080, "ctx":"main","msg":"\n\n***aborting after invariant() failure\n\n"} {"t":{"$date":"2023-01-09T14:57:45.295Z"},"s":"F", "c":"CONTROL", "id":6384300, "ctx":"main","msg":"Writing fatal message","attr":{"message":"\n"}} {"t":{"$date":"2023-01-09T14:57:45.295Z"},"s":"F", "c":"CONTROL", "id":6384300, "ctx":"main","msg":"Writing fatal message","attr":{"message":"Got signal: 6 (Aborted).\n"}} {"t":{"$date":"2023-01-09T14:57:45.304Z"},"s":"I", "c":"CONTROL", "id":31380, "ctx":"main","msg":"BACKTRACE","attr":{"bt":{"backtrace":[{"a":"7F12588668F9","b":"7F1258682000","o":"1E48F9","s":"_ZN5mongo18stack_trace_detail12_GLOBAL__N_117getStackTraceImplERKNS1_7OptionsE","C":"mongo::stack_trace_detail::(anonymous namespace)::getStackTraceImpl(mongo::stack_trace_detail::(anonymous namespace)::Options const&)","s+":"129"},{"a":"7F1258867920","b":"7F1258682000","o":"1E5920","s":"_ZN5mongo15printStackTraceEv","C":"mongo::printStackTrace()","s+":"30"},{"a":"7F1258862D2D","b":"7F1258682000","o":"1E0D2D","s":"abruptQuit","s+":"12D"},{"a":"7F12569F0980","b":"7F12569DE000","o":"12980","s":"funlockfile","s+":"50"},{"a":"7F125662BE87","b":"7F12565ED000","o":"3EE87","s":"gsignal","s+":"C7"},{"a":"7F125662D7F1","b":"7F12565ED000","o":"407F1","s":"abort","s+":"141"},{"a":"7F1258855E3B","b":"7F1258682000","o":"1D3E3B","s":"_ZN5mongo12_GLOBAL__N_19callAbortEv","C":"mongo::(anonymous namespace)::callAbort()","s+":"1B"},{"a":"7F1258855D0D","b":"7F1258682000","o":"1D3D0D","s":"_ZN5mongo15invariantFailedEPKcS1_j","C":"mongo::invariantFailed(char const*, char const*, unsigned int)","s+":"ED"},{"a":"7F1259190E3C","b":"7F125915A000","o":"36E3C","s":"_ZN5mongo22toInt128FromDecimal128ENS_10Decimal128E","C":"mongo::toInt128FromDecimal128(mongo::Decimal128)","s+":"21C"},{"a":"7F12591911F8","b":"7F125915A000","o":"371F8","s":"_ZN5mongo21getTypeInfoDecimal128ENS_10Decimal128EN5boost8optionalIS0_EES3_NS2_IjEE","C":"mongo::getTypeInfoDecimal128(mongo::Decimal128, boost::optional<mongo::Decimal128>, boost::optional<mongo::Decimal128>, boost::optional<unsigned int>)","s+":"318"},{"a":"557C523615A4","b":"557C5225D000","o":"1045A4","s":"_ZN5mongo62UnitTest_SuiteNameRangeTestTestNameDecimal128_Bounds_Precision7_doTestEv","C":"mongo::UnitTest_SuiteNameRangeTestTestNameDecimal128_Bounds_Precision::_doTest()","s+":"4A84"},{"a":"7F1259210F89","b":"7F12591E5000","o":"2BF89","s":"_ZN5mongo8unittest4Test3runEv","C":"mongo::unittest::Test::run()","s+":"19"},{"a":"557C5239BA7E","b":"557C5225D000","o":"13EA7E","s":"_ZZN5mongo8unittest4Test17RegistrationAgentINS_62UnitTest_SuiteNameRangeTestTestNameDecimal128_Bounds_PrecisionEEC1EPKNS0_8TestInfoEENKUlvE_clEv","C":"mongo::unittest::Test::RegistrationAgent<mongo::UnitTest_SuiteNameRangeTestTestNameDecimal128_Bounds_Precision>::RegistrationAgent(mongo::unittest::TestInfo const*)::{lambda()#1}::operator()() const","s+":"4E"},{"a":"7F125921282A","b":"7F12591E5000","o":"2D82A","s":"_ZN5mongo8unittest5Suite3runERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_i","C":"mongo::unittest::Suite::run(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)","s+":"42A"},{"a":"7F12592140D6","b":"7F12591E5000","o":"2F0D6","s":"_ZN5mongo8unittest5Suite3runERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS8_EERKS8_SE_i","C":"mongo::unittest::Suite::run(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)","s+":"606"},{"a":"7F125923C895","b":"7F1259237000","o":"5895","s":"main","s+":"E15"},{"a":"7F125660EC87","b":"7F12565ED000","o":"21C87","s":"__libc_start_main","s+":"E7"},{"a":"557C52301A8A","b":"557C5225D000","o":"A4A8A","s":"_start","s+":"2A"}],"processInfo":{"mongodbVersion":"unknown","gitVersion":"none","compiledModules":["unknown"],"uname":{"sysname":"Linux","release":"5.4.0-1085-aws","version":"#92~18.04.1-Ubuntu SMP Wed Aug 31 17:21:08 UTC 2022","machine":"x86_64"},"somap":[{"b":"557C5225D000","elfType":3,"buildId":"465A763F4D432B627410111E3B526D08BCEAD0DE"},{"b":"7F1259237000","path":"/home/ubuntu/mongo/build/install/bin/../lib/libunittest_main.so","elfType":3,"buildId":"499651BD0BF382F88709D18EDF39086B541D9BE7"},{"b":"7F12591E5000","path":"/home/ubuntu/mongo/build/install/bin/../lib/libunittest.so","elfType":3,"buildId":"947DCAFF87C10215EA72AB95C12D9159540A38E4"},{"b":"7F125915A000","path":"/home/ubuntu/mongo/build/install/bin/../lib/libfle_crypto.so","elfType":3,"buildId":"710E2BA20EDC3259CE4EDBE8253BB961D404FA2E"},{"b":"7F1258682000","path":"/home/ubuntu/mongo/build/install/bin/../lib/libbase.so","elfType":3,"buildId":"910FC70761C855A2191338C99E7AC5A7B309DE3C"},{"b":"7F12569DE000","path":"/lib/x86_64-linux-gnu/libpthread.so.0","elfType":3,"buildId":"8B60B9F8D9A27F2264A0D8E6C0768B3B02C29926"},{"b":"7F12565ED000","path":"/lib/x86_64-linux-gnu/libc.so.6","elfType":3,"buildId":"71F0F3074A929E519E85F6A5C03A7D1FD976BFE4"}]}}},"tags":[]} {"t":{"$date":"2023-01-09T14:57:45.304Z"},"s":"I", "c":"CONTROL", "id":31445, "ctx":"main","msg":"Frame","attr":{"frame":{"a":"7F12588668F9","b":"7F1258682000","o":"1E48F9","s":"_ZN5mongo18stack_trace_detail12_GLOBAL__N_117getStackTraceImplERKNS1_7OptionsE","C":"mongo::stack_trace_detail::(anonymous namespace)::getStackTraceImpl(mongo::stack_trace_detail::(anonymous namespace)::Options const&)","s+":"129"}}}

      toInt128FromDecimal128 has an invariant requiring the argument has no fractional part.

      Subtracting the min may result in a non-zero fractional part in this operation:

      Decimal128 v_prime2 = v_prime.subtract(min.get()).scale(precision.get());
      

      This only occurs if the min has more decimal places than the precision.

            Assignee:
            kevin.albertson@mongodb.com Kevin Albertson
            Reporter:
            kevin.albertson@mongodb.com Kevin Albertson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: