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

NullReferenceException for large amount of splice #745

Closed
OneFirefly opened this issue Jun 7, 2020 · 1 comment · Fixed by #746
Closed

NullReferenceException for large amount of splice #745

OneFirefly opened this issue Jun 7, 2020 · 1 comment · Fixed by #746

Comments

@OneFirefly
Copy link

Jint version: 3.0.0-beta-1828

Here is my C# code:

var engine = new Engine();
var parser = new JavaScriptParser(code);
var script = parser.ParseScript();
engine.Execute(script); //<--- NullReferenceException

Here is the js code I used:

let arr = [];
for (let i = 0; i < 10000; i++) arr.push(i);
for (let i=0;i<10000;i++) arr.splice(0, 1);

What happens?
I get a NullReferenceException in the line engine.Execute(script);

Here is the full stack trace from Visual Studio

 	Jint.dll!Jint.Native.Array.ArrayInstance.EnsureCapacity(uint capacity)	Unknown
 	Jint.dll!Jint.Native.Array.ArrayOperations.ArrayInstanceOperations.EnsureCapacity(ulong capacity)	Unknown
 	Jint.dll!Jint.Native.Array.ArrayPrototype.Splice(Jint.Native.JsValue thisObj, Jint.Native.JsValue[] arguments)	Unknown
 	Jint.dll!Jint.Runtime.Interop.ClrFunctionInstance.Call(Jint.Native.JsValue thisObject, Jint.Native.JsValue[] arguments)	Unknown
 	Jint.dll!Jint.Runtime.Interpreter.Expressions.JintCallExpression.EvaluateInternal()	Unknown
 	Jint.dll!Jint.Runtime.Interpreter.Expressions.JintExpression.Evaluate()	Unknown
 	Jint.dll!Jint.Runtime.Interpreter.Expressions.JintExpression.GetValue()	Unknown
 	Jint.dll!Jint.Runtime.Interpreter.Statements.JintExpressionStatement.ExecuteInternal()	Unknown
 	Jint.dll!Jint.Runtime.Interpreter.Statements.JintForStatement.ForBodyEvaluation()	Unknown
 	Jint.dll!Jint.Runtime.Interpreter.Statements.JintForStatement.ExecuteInternal()	Unknown
 	Jint.dll!Jint.Runtime.Interpreter.JintStatementList.Execute()	Unknown
 	Jint.dll!Jint.Engine.Execute(Esprima.Ast.Script program)	Unknown
>	jint playground.dll!jint_playground.Program.Main(string[] args) Line 40	C#

Note:
This only happens with large arrays (if I enter 1000 instead of 10000 it doesn't happen)
In case you can't reproduce the bug try adding a 0 to the 10000

@lahma
Copy link
Collaborator

lahma commented Jun 8, 2020

Thanks for reporting, created #746 to address the issue.

@lahma lahma closed this as completed in #746 Jun 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants