Question

My application is crashing with the following unhandled exception:

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: 

The call to SharpSvn.SvnClient.GetLog is here: https://github.com/tomhunter-gh/SourceLog/blob/2fa0632665550c18c9cd23500610704e3eaa35a2/SourceLog.Plugin.Subversion/SubversionPlugin.cs#L39

Was it helpful?

Solution

Looks like this is due to multiple timer callback instances calling GetLog at the same time and the fact that the method (SharpSvn in general?) isn't thread-safe. I've added a static lock object to ensure only one thread calls GetLog at a time.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top