I have an Asp .Net application for which I'm using the new async/await paradigm with .net 4.5 RC.
I am using the new task-based async http handler HttpTaskAsyncHandler
for handling http request. In my code i'm doing some I/O streaming a file to the client.
once in a while i'm getting a NullPointerException
with the following stack trace:
System.Web.dll!System.Web.HttpApplication.CurrentModuleContainer.get() + 0x1e bytes System.Web.dll!System.Web.HttpApplication.PipelineStepManager.ResumeSteps(System.Exception error) + 0xb7 bytes
System.Web.dll!System.Web.HttpApplication.CallHandlerExecutionStep.OnAsyncHandlerCompletion(System.IAsyncResult ar) + 0x1f3 bytes
mscorlib.dll!System.Threading.Tasks.Task.Execute() + 0x6e bytes mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) + 0x285 bytes mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) + 0x9 bytes
mscorlib.dll!System.Threading.Tasks.Task.ExecuteWithThreadLocal(ref System.Threading.Tasks.Task currentTaskSlot) + 0x1c5 bytes
mscorlib.dll!System.Threading.Tasks.Task.ExecuteEntry(bool bPreventDoubleExecution) + 0xb0 bytes
mscorlib.dll!System.Threading.ThreadPoolWorkQueue.Dispatch() + 0x1ea bytes
[Native to Managed Transition]
[Appdomain Transition]
[Native to Managed Transition]
This seems to happen after my code already returned the response.
When this happens the next request is just never handled, but the one after it is back to normal.
What could be the reason for this behavior? I took a peek at the source code for the CurrentModuleContainer.Get method and it seems that the only thing that can throw a null pointer exception is the Http context.