Uploaded image for project: 'MongoDB Shell'
  1. MongoDB Shell
  2. MONGOSH-1860

Memory leak on JavaScript syntax errors

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.3.0
    • Component/s: None
    • Environment:
    • Developer Tools

      Problem Statement/Rationale

      There is a memory leak if invalid javascript statements are executed using mongosh. Eventually, the JS interpreter complains that GC is ineffective and OOMs.

      Please be sure to attach relevant logs with any sensitive data redacted.
      How to retrieve logs for: Compass; Shell

      Steps to Reproduce

      Pipe the output of the following script to mongosh --nodb

      for i in range(1,1000000):
          print("a={'a':'b'} {'c', 'd'};"); 

      Expected Results

      I expect memory usage to remain constant as mongosh is executing commands.

      Actual Results

      Memory usage increases in a very obvious way as observed using top, followed by a JavaScript VM OOM and process exit.

      Additional Notes

      This seems to affect only syntax errors. If the script is syntactically valid but has other errors, e.g. a=no_such_variable, the memory usage remains constant.

      If mongosh and mongod are sharing a bunch of codebase, is it possible that a similar leak also affects mongod?

            Assignee:
            Unassigned Unassigned
            Reporter:
            philip.stoev@mongodb.com Philip Stoev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: