NullReferenceException - potential race condition? #131

Closed
josephlam opened this Issue Sep 18, 2013 · 0 comments

Projects

None yet

2 participants

@josephlam

I got this in my Windows event log:

An unhandled exception occurred and the process was terminated.

Application ID: /LM/W3SVC/1/ROOT/oa3

Process ID: 3432

Exception: System.NullReferenceException

Message: Object reference not set to an instance of an object.

StackTrace: at Enyim.Caching.CountdownEvent.Signal()
at Couchbase.CouchbaseClient.<>c__DisplayClass16.b__f(Boolean success)
at Couchbase.SyncOperation.<>c__DisplayClass2.b__1(Boolean readSuccess)
at Enyim.Caching.Memcached.Protocol.Binary.BinaryResponse.DoDecodeHeader(AsyncIOArgs asyncEvent, Boolean& pendingIO)
at Enyim.Caching.Memcached.Protocol.Binary.BinaryResponse.DoDecodeHeaderAsync(AsyncIOArgs asyncEvent)
at Enyim.Caching.Memcached.PooledSocket.AsyncSocketHelper.EndReceive()
at Enyim.Caching.Memcached.PooledSocket.AsyncSocketHelper.AsyncReadCompleted(Object sender, SocketAsyncEventArgs e)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Net.Sockets.SocketAsyncEventArgs.FinishOperationSuccess(SocketError socketError, Int32 bytesTransferred, SocketFlags flags)
at System.Net.Sockets.SocketAsyncEventArgs.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

It caused IIS / AppPool to crash. Looking at the source code I suspect it's a potential race condition where Enyim.Caching.CountdownEvent.mre was set to null by the Dispose() method while CouchbaseClient.PerformMultiSync() is calling .Signal() in an async operation (which calls this.mre.Set() triggering the NRE). Maybe there should be a null check before calling mre.Set()?

@enyim enyim added the wontfix label Apr 24, 2016
@enyim enyim closed this Apr 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment