Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

Edited Issue: [FIXED] AccessViolationException while calling Dispose on V8ScriptEngine from a Finalizer [51]

0
0
Hi,
I am getting an AccessViolationException while calling V8ScriptEngine from a finalizer.
I can reproduce the issue with below code:
____________________________________________________________________________________
```
namespace ClearScriptLoadTest
{
public class ClearScriptWrapper
{
private Microsoft.ClearScript.V8.V8ScriptEngine v8Engine;
public ClearScriptWrapper()
{
this.v8Engine = new Microsoft.ClearScript.V8.V8ScriptEngine(Microsoft.ClearScript.V8.V8ScriptEngineFlags.None);
}
~ClearScriptWrapper()
{
Console.WriteLine("Finalizer called");
v8Engine.Dispose();
}
}


class Program
{
static void Main(string[] args)
{
for (int i = 0; i < 1000000; i++)
{
ClearScriptWrapper csObj = new ClearScriptWrapper();
GC.Collect();
}
}
}
}

```

____________________________________________________________________________________

__Exception :__

Unhandled Exception: System.AccessViolationException: Attempted to read or write
protected memory. This is often an indication that other memory is corrupt.
at RefCount.Increment(RefCount* )
at SharedPtr<V8Context>.=(SharedPtr<V8Context>* , SharedPtr<V8Context>* that)

at Microsoft.ClearScript.V8.V8ContextProxyImpl.~V8ContextProxyImpl()
at Microsoft.ClearScript.V8.V8ContextProxyImpl.Dispose(Boolean A_0)
at Microsoft.ClearScript.V8.V8ContextProxyImpl.Dispose()
at Microsoft.ClearScript.V8.V8ScriptEngine.Dispose(Boolean disposing)
at Microsoft.ClearScript.ScriptEngine.Dispose()
at ClearScriptLoadTest.ClearScriptWrapper.Finalize() in c:\Users\xxxxxx\Doc
uments\Visual Studio 2013\Projects\ClearScriptLoadTest\ClearScriptLoadTest\Progr
am.cs:line 18

It works fine when dispose is deterministic .

regards
```
skpandey
```

Viewing all articles
Browse latest Browse all 2297