Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Engine.Execute throws OutOfMemoryException after 45s (even with the 2s timeout) #587

Closed
Metalnem opened this issue Jan 20, 2019 · 1 comment
Labels

Comments

@Metalnem
Copy link

The following program runs for about 45s (even though I've set the timeout interval to 2s) before finally throwing the OutOfMemoryException. You have to run in on .NET Framework 4.7.2 to reproduce it (this code hangs permanently on .NET Core, which I think is due to an issue in .NET Core itself).

using System;

namespace Jint.Run
{
  public class Program
  {
    public static void Main(string[] args)
    {
      new Engine(SetOptions).Execute("'x'.match(/|/g);");
    }

    private static void SetOptions(Options options)
    {
      options.LimitRecursion(32).TimeoutInterval(TimeSpan.FromSeconds(2));
    }
  }
}

Here are the exception details:

System.OutOfMemoryException
  HResult=0x8007000E
  Message=Array dimensions exceeded supported range.
  Source=mscorlib
  StackTrace:
   at System.Collections.Generic.Dictionary`2.Resize(Int32 newSize, Boolean forceNewHashCodes)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at Jint.Native.String.StringPrototype.Match(JsValue thisObj, JsValue[] arguments)
   at Jint.Runtime.Interop.ClrFunctionInstance.Call(JsValue thisObject, JsValue[] arguments)
   at Jint.Runtime.ExpressionInterpreter.EvaluateCallExpression(CallExpression callExpression)
   at Jint.Engine.ExecuteStatement(Statement statement)
   at Jint.Runtime.StatementInterpreter.ExecuteSingleStatement(Statement s)
   at Jint.Engine.Execute(Program program)

Found via SharpFuzz.

lahma added a commit to lahma/jint that referenced this issue May 25, 2019
@lahma lahma added the bug label May 25, 2019
@lahma
Copy link
Collaborator

lahma commented May 25, 2019

Thanks for reporting this, fixed via #626

@lahma lahma closed this as completed May 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants