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

Write a test to ensure SBE's implementation of multiply succeeds in edge cases



    • Task
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 5.2.0, 5.1.0-rc3
    • None
    • None
    • Fully Compatible
    • v5.1
    • QE 2021-10-18, QE 2021-11-01


      This is a follow-up to BF-22891. It seems that this is actually a classic engine bug and SERVER-60588 will permanently fix the issue, but we want to write a test to see if there are any other bugs in SBE's implementation of $multiply that we don't know about. We should be able to run this test in both the classic and SBE engines and get the same results.

      We could try calling $multiply with 2 args and 3 args with every possible combination of types. We should test very small and very large values: 1, 2^32, 2^32-1, -1, as well as the limits of each of the types that may cause an overflow.

      Here's a repro of one failure, the one that occurred in the original BF:
      > db.fuzzer_coll.drop();
      > db.fuzzer_coll.insert([{_id: 13}, {_id: 14, num: 1}]);
      > db.fuzzer_coll.aggregate([{$sort: {_id: 1}}, {$limit: 20}, {$graphLookup: {from: "fuzzer_coll", startWith: {$filter: {input: "$array", cond: {$or: []}}}, connectFromField: "nonexistent", connectToField: "nonexistent", as: "array", restrictSearchWithMatch: {$expr: {$multiply: ["$num", NumberLong("314159265358979393"), NumberLong("-314159265358979323")]}}}}]);

      In the v5.1 shell, this results in:
      { "_id" : 13, "array" : [ { "_id" : 14, "num" : 1 } ] }
      { "_id" : 14, "num" : 1, "array" : [ { "_id" : 14, "num" : 1 } ] }

      In the v5.0 shell, however, it triggers an error: "Can't coerce out of range value -9.8696e+34 to long."


        Issue Links



              jennifer.peshansky@mongodb.com Jennifer Peshansky (Inactive)
              jennifer.peshansky@mongodb.com Jennifer Peshansky (Inactive)
              0 Vote for this issue
              6 Start watching this issue