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 in DefaultTypeConverter #619

Closed
alexmg opened this issue Apr 12, 2019 · 0 comments · Fixed by #620
Closed

NullReferenceException in DefaultTypeConverter #619

alexmg opened this issue Apr 12, 2019 · 0 comments · Fixed by #620

Comments

@alexmg
Copy link
Contributor

alexmg commented Apr 12, 2019

I am seeing the NullReferenceException below when unit tests are being executed concurrently. It appears some reordering might be causing the double locking that is in place to not behave as expected.

System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
   at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
   at Jint.Runtime.Interop.DefaultTypeConverter.TryConvert(Object value, Type type, IFormatProvider formatProvider, Object& converted)
   at Jint.Runtime.Descriptors.Specialized.IndexDescriptor..ctor(Engine engine, Type targetType, String key, Object item)
   at Jint.Runtime.Interop.ObjectWrapper.<>c__DisplayClass9_0.<ResolveProperty>b__3(Engine engine, Object target)
   at Jint.Runtime.Interop.ObjectWrapper.GetOwnProperty(String propertyName)
   at Jint.Native.Object.ObjectInstance.Get(String propertyName)
   at Jint.Engine.GetValue(Reference reference, Boolean returnReferenceToPool)
   at Jint.Runtime.Interpreter.Expressions.JintBinaryExpression.JintGenericBinaryExpression.EvaluateInternal()
   at Jint.Runtime.Interpreter.Expressions.JintExpression.GetValue()
   at Jint.Runtime.Interpreter.Expressions.JintExpression.BuildArguments(JintExpression[] jintExpressions, JsValue[] targetArray)
   at Jint.Runtime.Interpreter.Expressions.JintCallExpression.EvaluateInternal()
   at Jint.Runtime.Interpreter.Expressions.JintExpression.GetValue()
   at Jint.Runtime.Interpreter.Statements.JintExpressionStatement.ExecuteInternal()
   at Jint.Runtime.Interpreter.JintStatementList.Execute()
   at Jint.Engine.Execute(Program program)

I can confirm that the problem is not reproducible when using a ConcurrentDictionary<string, bool> instead of Dictionary<string, bool> with locking. I will submit a PR with these changes for your consideration.

alexmg added a commit to alexmg/jint that referenced this issue Apr 12, 2019
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.

1 participant