parush / elmah

Automatically exported from code.google.com/p/elmah
0 stars 0 forks source link

System.NullReferenceException when downloading error log in csv format #42

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This is the stack trace:

System.NullReferenceException: Object reference not set to an instance of
an object.
   at
System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.I
ExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
completedSynchronously)

This is happening both in ASP.NET 1.1 and 2.0, with a subtle difference.

The environment is XP2 OS, IIS 5.1 web server, and .NET frameworks 1.1 and 2.0.

These are the steps to reproduce the issue:

1. browse to elmax.axd handler to show the error list.
2. click the "DOWNLOAD LOG" link
3. either download the file or cancel the transfer
4. refresh the page
5. a NullReferenceException exception has been logged by ELMAH and appears
in the error list

Subtle difference in .NET 1.1/2.0: if the csv log is downloaded again and
again, for each try in .NET 1.1 a new NullReferenceException gets logged,
while in .NET 2.0 it happens just on the first attempt to download the log
file.

Original issue reported on code.google.com by simone.b...@gmail.com on 3 Nov 2007 at 12:06

GoogleCodeExporter commented 9 years ago

Original comment by azizatif on 3 Nov 2007 at 12:36

GoogleCodeExporter commented 9 years ago

Original comment by azizatif on 4 Nov 2007 at 2:56

GoogleCodeExporter commented 9 years ago

Original comment by azizatif on 4 Nov 2007 at 2:57

GoogleCodeExporter commented 9 years ago
This was a tough cookie, but fixed in r236. The problem occurred due to 
synchronous 
completion of an asynchronous operation. More specifically, 
ErrorLogDownloadHandler.BeginProcessRequest could return a null IAsyncResult if 
the 
downstream ErrorLog.BeginGetErrors operation completed synchronously. The 
problem 
was solved by copying a reference of the IAsyncResult object on the stack from 
within ErrorLogDownloadHandler.BeginProcessRequest.

Original comment by azizatif on 4 Nov 2007 at 3:00

GoogleCodeExporter commented 9 years ago
So was I almost right? ;) Actually, making _result null removed the only 
reference to
that object.

Original comment by simone.b...@gmail.com on 4 Nov 2007 at 10:46

GoogleCodeExporter commented 9 years ago
Almost, right. :) Removing the _result reference as you suggested would have 
helped 
this once case but it would have been logically not the right solution and 
therefore 
probably caused another bug somewhere down the road. However, given the fix I 
made, 
I can now see how what you were suggesting seemed to make things look alright. 
Also, 
it explains why it always occurred in 1.x but only seldom in 2.0. The 
SqlErrorLog is 
always synchronous under 1.x but synchronous/asynchronous under 2.0. The bug 
was 
with synchronous completion of asynchronous requests and that could happen from 
time 
to time.

Original comment by azizatif on 4 Nov 2007 at 11:38