[Mono-bugs] [Bug 78583][Nor] New - HttpContext.Current is null when HttpRuntime.ProcessRequest is called from a regular thread

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Mon Jun 5 08:42:42 EDT 2006


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by andrews at mainsoft.com.

http://bugzilla.ximian.com/show_bug.cgi?id=78583

--- shadow/78583	2006-06-05 08:42:42.000000000 -0400
+++ shadow/78583.tmp.4440	2006-06-05 08:42:42.000000000 -0400
@@ -0,0 +1,62 @@
+Bug#: 78583
+Product: Mono: Class Libraries
+Version: unspecified
+OS: All
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Sys.Web
+AssignedTo: gonzalo at ximian.com                            
+ReportedBy: andrews at mainsoft.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: HttpContext.Current is null when HttpRuntime.ProcessRequest is called from a regular thread
+
+Description of Problem:
+HttpContext.Current is null when HttpRuntime.ProcessRequest is called from 
+a regular thread (not from ThreadPool thread). This happens only with user 
+web hosting, because XSP allways calls HttpRuntime.ProcessRequest from a 
+ThreadPool thread (see ApplicationServer.RunServer and ApplicationServer.
+ReuseSocket).
+
+Steps to reproduce the problem:
+1. go to System.Web/Test/standalone/hosting/test1
+2. make run-test
+
+Actual Results:
+Null pointer exception
+
+Expected Results:
+html output of the page with master page
+
+How often does this happen? 
+Always
+
+Additional Information:
+1. HttpRuntime.ProcessRequest call RealProcessRequest
+2a. RealProcessRequests sets HttpContext.Current (and it's stored in a 
+CallContext.SetData ("c") - name is too short, BTW)
+2b. RealProcessRequest calls IHttpAsyncHandler.BeginProcessRequest
+3. HttpApplication.IHttpAsyncHandler.BeginProcessRequest checks 
+
+    if (Thread.CurrentThread.IsThreadPoolThread)
+
+and makes a synchronous call to Start when it's true. This is what happens 
+in XSPApplicationHost, because HttpRuntime is called from 
+XSPApplicationHost.InnerRun which is called from IWorker.Run which is 
+called always via ThreadPool. So when condition above is true, HttpRuntime.
+RealProcessRequest and HttpApplication.Start run in the _same_thread_, and 
+HttpContext.Current is valid.
+
+If a host is created with ApplicationHost.CreateApplicationHost, and no 
+thread pool is used to call HttpRuntime.ProcessRequest, then HttpRuntime.
+RealProcessRequest and HttpApplication.Start will run in 
+_different_threads_, and HttpContext.Current will be null in 
+HttpApplication.Start. What goes on next is seen in the attached call 
+stack. PageParser.ProcessMainAttributes calls GetCompiledMasterType with 
+HttpContext.Current==null and this null context gets to TemplateParser.
+AddApplicationAssembly where it causes null pointer exception.


More information about the mono-bugs mailing list