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

Segmentation fault when nested documents too deep.

    • Type: Icon: Bug Bug
    • Resolution: Community Answered
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 5.0.6, 4.4.11
    • Component/s: None
    • None
    • ALL
    • Hide

      1) Insert a document into a collection ('test' in my code). Fields are irrelevant.

      2) From the shell, run below code on the collection.

      var my_arr = []

      for (var i = 0; i <= 150000; i++) my_arr.push

      db.test.aggregate([
      {$project: {
      "random_field_name": {
      $reduce: {
      "input": my_arr,
      "initialValue": "this_value_does_not_matter",
      "in":

      { "this_name_does_not_matter_TWO": "$$value" }

      }
      }
      }
      }
      ])

      Show
      1) Insert a document into a collection ('test' in my code). Fields are irrelevant. 2) From the shell, run below code on the collection. var my_arr = [] for (var i = 0; i <= 150000; i++) my_arr.push db.test.aggregate([ {$project: { "random_field_name": { $reduce: { "input": my_arr, "initialValue": "this_value_does_not_matter", "in": { "this_name_does_not_matter_TWO": "$$value" } } } } } ])

      A Segmentation Fault occurs when nested documents get to a certain level. On my machine it was ~13000. This isn't terribly important to me (I found it because of a bug in my own code) but I don't think a Segmentation Fault is ever supposed to happen. Also it is fairly simple to reproduce. This crashed both a simple 3 server replica set (will crash secondaries if 'prefer_secondary' is enabled) as well as a single server.  The Segmentation Fault seems much more pronounced on the replica set (I am probably just a noob at reading MongoDB status though).

      I am running Ubuntu 20.04.3 LTS and I tried this on MongoDB releases 5.0.6 and 4.4.11.

        1. admin_getParameters
          14 kB
        2. admin_parameters
          14 kB
        3. replica_set_primary_1_12898.log
          82 kB
        4. replica_set_primary_instance_mongodb.log
          79 kB
        5. single_server_instance_mongod.log
          43 kB

            Assignee:
            dmitry.agranat@mongodb.com Dmitry Agranat
            Reporter:
            letsgoappworker101@gmail.com Jeremiah Gleason
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: