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

Use of "scope" field in mapReduce triggers BSONObj ownership error

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Critical - P2 Critical - P2
    • 3.2.17, 3.4.9, 3.5.13
    • Affects Version/s: 3.4.8
    • Component/s: JavaScript
    • Fully Compatible
    • ALL
    • v3.4, v3.2
    • Platforms 2017-09-11

      "scope" allows a user to provide a map of global variables to expose to all JS functions ran during a mapReduce job. However, we do not take an owned copy of the map from the command. If scope contains an object, this triggers the memory protection mechanisms added in SERVER-30875.

      MongoDB Enterprise > db.runCommand({mapReduce: "foo", map: function(x) {return emit("hello", 1);}, reduce: function(x) { return 0; }, scope: {x: {x: function() {return 5;}}}, out: "bar"})
      {
              "ok" : 0,
              "errmsg" : "Attempt to bind an unowned BSON Object to a JS scope marked as requiring ownership",
              "code" : 2,
              "codeName" : "BadValue"
      }
      

            Assignee:
            spencer.jackson@mongodb.com Spencer Jackson
            Reporter:
            spencer.jackson@mongodb.com Spencer Jackson
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: