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

SBE plans may trigger stack overflow

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.1.0-rc0
    • Component/s: None
    • Labels:
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Requested:
      v5.0
    • Sprint:
      Query Execution 2021-05-31, Query Execution 2021-06-14
    • Linked BF Score:
      137

      Description

      filterObj = {}; for (let i = 0; i < 225; ++i) { filterObj["foo" + i] = 123; }
      db.coll.runCommand({explain: {find: "coll", filter: filterObj}}) 

      This was enough to trigger it on an optimized build on my machine. An unoptimized build will likely fair worse.

      The implicit ANDs in the filter are translated in a way which makes each clause of the AND a child of the previous one (instead of a sibling). This is known as the "top level AND optimization." With such a deep tree, when each stack frame is large, it is quite easy to overflow.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              ian.boros Ian Boros
              Reporter:
              ian.boros Ian Boros
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: