0

我对 C++/CLI 不是很熟悉,但我很久以前做过一些 C++。我正在尝试在项目内部的方法中调试AccessViolationException我在 WebKit.NET 中的内容。这是导致异常的代码行:JSContext::EvaluateScriptJSCore

JSValueRef result = NULL;

try
{
    result = JSEvaluateScript(_context, jsScript, /*(JSObjectRef)jsObj*/NULL, NULL, 0, &exception);
}
catch(...)
{
}

此错误将随机发生。我知道_context并且jsScript不为空。奇怪的是,当错误发生时,Program.cs 文件打开并且异常出现在Application.Run(new Form1());带有 a 的行上TargetInvocationException,但我可以在 IntelliTrace 中看到,在此AccessViolationException之前,在上面引用的行之前发生了这种情况,所以我假设这是导致该异常的异常TargetInvocationException

result = JSEvaluateScript...另外,如果我在上面的行中设置了一个断点(一。此外,JSEvaluateScriptWebKitdll 内,所以我无法进入它。

但是,try/catch最初不存在的 似乎没有捕捉到异常,所以我不确定发生了什么。我可以通过在我的应用程序中执行一组操作来重现错误,但无法理解为什么这些操作会导致错误。大多数时候JSContext::EvaluateScript使用相同的参数调用不会导致异常。

有关如何诊断此问题的任何建议?我没主意了。

编辑:我只是做了更多的调试,错误也可能发生在其他一些随机行。所以我很确定与上面的行无关。

编辑2:这是堆栈跟踪:

>   JSCore.dll!WebKit.JSCore.JSContext.EvaluateScript(string script = {unknown}, object thisObject = {unknown}, string sourceUrl = {unknown}, int startingLineNumber = {unknown})   
    JSCore.dll!WebKit.JSCore.JSContext.EvaluateScript(string script = {unknown})    
    WebKitBrowserTest.exe!Player.WebKitWraps.JSObjectWrap.GetExpando()  
    WebKitBrowserTest.exe!Get Player.WebKitWraps.JSObjectWrap.Expando() 
    WebKitBrowserTest.exe!Player.WebKitWraps.JSObjectWrap.Equals(Player.WebKitWraps.JSObjectWrap other = {Player.WebKitWraps.ElementWrap})  
    WebKitBrowserTest.exe!Player.WebKitWraps.JSObjectWrap.op_Equality(Player.WebKitWraps.JSObjectWrap a = {Player.WebKitWraps.ElementWrap}, Player.WebKitWraps.JSObjectWrap b = {Player.WebKitWraps.ElementWrap})   
    WebKitBrowserTest.exe!Player.WebKitWraps.JSObjectWrap.op_Inequality(Player.WebKitWraps.JSObjectWrap a = {Player.WebKitWraps.ElementWrap}, Player.WebKitWraps.JSObjectWrap b = {Player.WebKitWraps.ElementWrap}) 
    WebKitBrowserTest.exe!WebScraperAndPlayer.SelectionEditor.SelectPrevSibling(WebScraperAndPlayer.BrowserSelector selector = {WebScraperAndPlayer.BrowserSelector})   
    WebKitBrowserTest.exe!WebScraperAndPlayer.SelectionEditor.WillSelectAny(System.Action<WebScraperAndPlayer.BrowserSelector> selectFunction = {System.Action<WebScraperAndPlayer.BrowserSelector>})   
    WebKitBrowserTest.exe!WebScraperAndPlayer.SelectionEditor.UpdateAbilities() 
    WebKitBrowserTest.exe!WebScraperAndPlayer.SelectionEditor.SetExecutionState(Player.Actions.ExecutionState value = Stopped)  
    WebKitBrowserTest.exe!Set WebScraperAndPlayer.SelectionEditor.ExecutionState(Player.Actions.ExecutionState value = Stopped) 
    mscorlib.dll!System.RuntimeMethodHandle.InvokeMethodFast(System.IRuntimeMethodInfo method = {unknown}, object target = {unknown}, object[] arguments = {unknown}, System.Signature sig = {unknown}, System.Reflection.MethodAttributes methodAttributes = {unknown}, System.RuntimeType typeOwner = {unknown})  
    mscorlib.dll!System.Reflection.RuntimeMethodInfo.Invoke(object obj = {unknown}, System.Reflection.BindingFlags invokeAttr = {unknown}, System.Reflection.Binder binder = {unknown}, object[] parameters = {unknown}, System.Globalization.CultureInfo culture = {unknown}, bool skipVisibilityChecks = {unknown})   
    mscorlib.dll!System.Reflection.RuntimeMethodInfo.Invoke(object obj = {unknown}, System.Reflection.BindingFlags invokeAttr = {unknown}, System.Reflection.Binder binder = {unknown}, object[] parameters = {unknown}, System.Globalization.CultureInfo culture = {unknown})  
    mscorlib.dll!System.Reflection.MethodBase.Invoke(object obj = {unknown}, object[] parameters = {unknown})   
    System.dll!System.SecurityUtils.MethodInfoInvoke(System.Reflection.MethodInfo method = {unknown}, object target = {unknown}, object[] args = {unknown}) 
    System.dll!System.ComponentModel.ReflectPropertyDescriptor.SetValue(object component = {unknown}, object value = {unknown}) 
    System.Windows.Forms.dll!System.Windows.Forms.Binding.SetPropValue(object value = {unknown})    
    System.Windows.Forms.dll!System.Windows.Forms.Binding.PushData(bool force = {unknown})  
    System.Windows.Forms.dll!System.Windows.Forms.Binding.PushData()    
    System.Windows.Forms.dll!System.Windows.Forms.BindingManagerBase.PushData(out bool success = {unknown}) 
    System.Windows.Forms.dll!System.Windows.Forms.BindingManagerBase.PushData() 
    System.Windows.Forms.dll!System.Windows.Forms.PropertyManager.OnCurrentChanged(System.EventArgs ea = {unknown}) 
    System.Windows.Forms.dll!System.Windows.Forms.BindToObject.PropValueChanged(object sender = {unknown}, System.EventArgs e = {unknown})  
    System.dll!System.ComponentModel.PropertyDescriptor.OnValueChanged(object component = {unknown}, System.EventArgs e = {unknown})    
    System.dll!System.ComponentModel.ReflectPropertyDescriptor.OnValueChanged(object component = {unknown}, System.EventArgs e = {unknown}) 
    System.dll!System.ComponentModel.ReflectPropertyDescriptor.OnINotifyPropertyChanged(object component = {unknown}, System.ComponentModel.PropertyChangedEventArgs e = {unknown}) 
    WebKitBrowserTest.exe!Player.Project.BasicProject.NotifyPropertyChanged(string propertyName = "ExecutionState") 
    WebKitBrowserTest.exe!Player.Project.BasicProject.SetInternalExecutionState(InternalExecutionState value = Stopped) 
    WebKitBrowserTest.exe!Player.Project.BasicProject.execData_ExecutionCompleted(object sender = {Player.Actions.ExecutionData}, Player.Actions.ExecutionCompletedEventArgs e = {Player.Actions.ExecutionCompletedEventArgs})  
    WebKitBrowserTest.exe!Player.Actions.ExecutionData.OnExecutionCompleted(Player.Actions.ExecutionCompletedEventArgs e = {Player.Actions.ExecutionCompletedEventArgs})    
    WebKitBrowserTest.exe!Player.Actions.ExecutionData.ReportExecutionCompleted(Player.Actions.StopException exception = null)  
    WebKitBrowserTest.exe!Player.Actions.Executor.ProcessExecutionCompleted(Player.Actions.StopException exception = null)  
    WebKitBrowserTest.exe!Player.Actions.Executor.StartNextSegment()    
    WebKitBrowserTest.exe!Segment.Conclude()    
    WebKitBrowserTest.exe!<>c__DisplayClass5.AnonymousMethod()  
    WebKitBrowserTest.exe!Player.Actions.Waiter.OnCallbackFunction()    
    WebKitBrowserTest.exe!Player.Actions.Waiter.Complete()  
    WebKitBrowserTest.exe!Player.Actions.Waiter.AnonymousMethod()   
    mscorlib.dll!System.RuntimeMethodHandle.InvokeMethodFast(System.IRuntimeMethodInfo method = {unknown}, object target = {unknown}, object[] arguments = {unknown}, System.Signature sig = {unknown}, System.Reflection.MethodAttributes methodAttributes = {unknown}, System.RuntimeType typeOwner = {unknown})  
    mscorlib.dll!System.Reflection.RuntimeMethodInfo.Invoke(object obj = {unknown}, System.Reflection.BindingFlags invokeAttr = {unknown}, System.Reflection.Binder binder = {unknown}, object[] parameters = {unknown}, System.Globalization.CultureInfo culture = {unknown}, bool skipVisibilityChecks = {unknown})   
    mscorlib.dll!System.Delegate.DynamicInvokeImpl(object[] args = {unknown})   
    mscorlib.dll!System.Delegate.DynamicInvoke(object[] args = {unknown})   
    System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme = {unknown})  
    System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(object obj = {unknown}) 
    mscorlib.dll!System.Threading.ExecutionContext.runTryCode(object userData = {unknown})  
    mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext = {unknown}, System.Threading.ContextCallback callback = {unknown}, object state = {unknown}) 
    mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext = {unknown}, System.Threading.ContextCallback callback = {unknown}, object state = {unknown}, bool ignoreSyncCtx = {unknown}) 
    mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext = {unknown}, System.Threading.ContextCallback callback = {unknown}, object state = {unknown}) 
    System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme = {unknown})    
    System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbacks()    
    System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m = {unknown})   
    System.Windows.Forms.dll!System.Windows.Forms.ScrollableControl.WndProc(ref System.Windows.Forms.Message m = {unknown}) 
    System.Windows.Forms.dll!System.Windows.Forms.ContainerControl.WndProc(ref System.Windows.Forms.Message m = {unknown})  
    System.Windows.Forms.dll!System.Windows.Forms.Form.WndProc(ref System.Windows.Forms.Message m = {unknown})  
    System.Windows.Forms.dll!ControlNativeWindow.OnMessage(ref System.Windows.Forms.Message m = {unknown})  
    System.Windows.Forms.dll!ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m = {unknown})    
    System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr hWnd = {unknown}, int msg = {unknown}, System.IntPtr wparam = {unknown}, System.IntPtr lparam = {unknown})  
    System.Windows.Forms.dll!ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(System.IntPtr dwComponentID = {unknown}, int reason = {unknown}, int pvLoopData = {unknown})   
    System.Windows.Forms.dll!ThreadContext.RunMessageLoopInner(int reason = {unknown}, System.Windows.Forms.ApplicationContext context = {unknown}) 
    System.Windows.Forms.dll!ThreadContext.RunMessageLoop(int reason = {unknown}, System.Windows.Forms.ApplicationContext context = {unknown})  
    System.Windows.Forms.dll!System.Windows.Forms.Application.Run(System.Windows.Forms.Form mainForm = {unknown})   
    WebKitBrowserTest.exe!WebScraperAndPlayer.Program.Main(string[] args = {string[0]}) 
4

0 回答 0