1

我的应用程序因以下未处理的异常而崩溃:

System.AccessViolationException was unhandled
  HResult=-2147467261
  Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
  Source=SharpSvn
  StackTrace:
       at apr_pool_destroy(apr_pool_t* )
       at SharpSvn.Implementation.AprPool.Destroy()
       at SharpSvn.Implementation.AprPool.Dispose(Boolean )
       at SharpSvn.Implementation.AprPool.Dispose()
       at SharpSvn.SvnClient.InternalLog(ICollection`1 targets, Uri logRoot, SvnRevision altPegRev, SvnLogArgs args, EventHandler`1 logHandler)
       at SharpSvn.SvnClient.Log(Uri target, SvnLogArgs args, EventHandler`1 logHandler)
       at SharpSvn.SvnClient.GetLog(Uri target, SvnLogArgs args, Collection`1& logItems)
       at SourceLog.Plugin.Subversion.SubversionPlugin.CheckForNewLogEntries(Object state)
       at System.Threading.TimerQueueTimer.CallCallbackInContext(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.TimerQueueTimer.CallCallback()
       at System.Threading.TimerQueueTimer.Fire()
       at System.Threading.TimerQueue.FireQueuedTimerCompletion(Object state)
       at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
       at System.Threading.ThreadPoolWorkQueue.Dispatch()
       at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
  InnerException: 

对 SharpSvn.SvnClient.GetLog 的调用在这里:https ://github.com/tomhunter-gh/SourceLog/blob/2fa0632665550c18c9cd23500610704e3eaa35a2/SourceLog.Plugin.Subversion/SubversionPlugin.cs#L39

4

1 回答 1

1

看起来这是由于多个计时器回调实例同时调用 GetLog 以及该方法(通常是 SharpSvn?)不是线程安全的事实。我添加了一个静态锁对象,以确保一次只有一个线程调用 GetLog。

于 2012-12-02T00:49:35.833 回答