[Mono-dev] Deadlock in System.Web.Caching.Cache class

Ivan Radovanovic rivanr at gmail.com
Mon Nov 9 04:11:13 EST 2009


Issue was in bad patch applied on mono/metadata/filewatcher.c - so no 
errors on mono side :-)
I will try to create test case for this deadlock, since it is not OS 
dependent, but anyway I don't think it is very serious

Best regards,
Ivan

Marek Habersack napisa:
> Ivan Radovanovic wrote:
>> Although this dead lock problem continues to potentially exists it 
>> seems that problem is after all OS specific - there is some weird 
>> behavior of fam/gamin reporting that bin/*.dll files are changed, 
>> causing ASP.Net runtime trying to restart application, while at the 
>> same time trying to compile *.aspx, *.ascx etc.
> The issue might be in FAM FileSystemWatcher backend then.
> 
>> Maybe deadlock can occur in normal conditions too (servicing some 
>> request that would need compiling of some control/page that is not 
>> compiled yet and replacing something in bin directory at the same 
>> time), but that should be rare enough :-)
> The BuildManager in 2.4 has some bugs indeed, which in certain cases can 
> lead to deadlocks (it's, among others, related to recursive dependencies 
> between application files). For that reason I rewrote BuildManager for 
> 2.6+ - if the problem you're seeing turns out to be an issue with more 
> than few environments, I can just copy the new code to 2.4 branch for a 
> future release. If you can come up with a test case that triggers the 
> issue on your system, then please file a bug report and attach the 
> testcase including OS/environment details.
> 
> marek
>>
>> Regards
>>
>> Ivan Radovanovic napisa:
>>> Hello, I am experiencing weird deadlock in .net applications running 
>>> latest release version of mono (2.4.2.3) on FreeBSD (I don't think it 
>>> is OS specific, and it doesn't show all the times, but still often 
>>> enough so I can trace it)
>>>
>>> Stack from thread 1:
>>>    at 
>>> System.Web.Compilation.BuildManager.RemoveVirtualPathFromCaches(System.Web.VirtualPath 
>>> virtualPath)
>>>    at 
>>> System.Web.Compilation.BuildManager.OnVirtualPathChanged(System.String 
>>> key, System.Object value, CacheItemRemovedReason removedReason)
>>>    at System.Web.Caching.Cache.InvokePrivateCallbacks()
>>>    at System.Web.HttpRuntime.ShutdownAppDomain(System.Object args)
>>> ====================================================================
>>> Stack from thread 2:
>>>    at System.Web.Caching.Cache.Add(System.String key, System.Object 
>>> value, System.Web.Caching.CacheDependency dependencies, DateTime 
>>> absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority 
>>> priority, System.Web.Caching.CacheItemRemovedCallback onRemoveCallback)
>>>    at System.Web.Compilation.BuildManager.AddToCache(System.String 
>>> virtualPath, System.Web.Compilation.BuildProvider bp)
>>>    at 
>>> System.Web.Compilation.BuildManager.GenerateAssembly(System.Web.Compilation.AssemblyBuilder 
>>> abuilder, System.Collections.Generic.List`1 buildItems, 
>>> System.Web.VirtualPath virtualPath, BuildKind buildKind)
>>>    at 
>>> System.Web.Compilation.BuildManager.BuildAssembly(System.Web.VirtualPath 
>>> virtualPath)
>>>    at 
>>> System.Web.Compilation.BuildManager.GetCompiledType(System.String 
>>> virtualPath)
>>>    at 
>>> System.Web.Compilation.AspComponentFoundry+TagNameFoundry.LoadType()
>>>    at 
>>> System.Web.Compilation.AspComponentFoundry+TagNameFoundry.GetType(System.String 
>>> componentName, System.String ByRef source, System.String ByRef ns)
>>>    at 
>>> System.Web.Compilation.AspComponentFoundry.CreateComponent(System.Web.Compilation.Foundry 
>>> foundry, System.String tagName, System.String prefix, System.String tag)
>>>    at 
>>> System.Web.Compilation.AspComponentFoundry.GetComponent(System.String 
>>> tagName)
>>>    at System.Web.UI.RootBuilder.GetChildControlType(System.String 
>>> tagName, IDictionary attribs)
>>>    at System.Web.UI.ControlBuilder.CreateSubBuilder(System.String 
>>> tagid, System.Collections.Hashtable atts, System.Type childType, 
>>> System.Web.UI.TemplateParser parser, ILocation location)
>>>    at System.Web.Compilation.AspGenerator.ProcessTag(ILocation 
>>> location, System.String tagid, System.Web.Compilation.TagAttributes 
>>> atts, TagType tagtype, Boolean ByRef ignored)
>>>    at System.Web.Compilation.AspGenerator.TagParsed(ILocation 
>>> location, TagType tagtype, System.String tagid, 
>>> System.Web.Compilation.TagAttributes attributes)
>>>    at System.Web.Compilation.AspParser.OnTagParsed(TagType tagtype, 
>>> System.String id, System.Web.Compilation.TagAttributes attributes)
>>>    at System.Web.Compilation.AspParser.Parse()
>>>    at System.Web.Compilation.AspGenerator.Parse(System.IO.TextReader 
>>> reader, System.String filename, Boolean doInitParser)
>>>    at System.Web.Compilation.GenericBuildProvider`1.Parse()
>>>    at 
>>> System.Web.Compilation.GenericBuildProvider`1.get_CodeCompilerType()
>>>    at 
>>> System.Web.Compilation.BuildManager.GetCodeDomProviderType(System.Web.Compilation.BuildProvider 
>>> provider)
>>>    at 
>>> System.Web.Compilation.BuildManager+BuildItem..ctor(System.Web.Compilation.BuildProvider 
>>> provider)
>>>    at 
>>> System.Web.Compilation.BuildManager.LoadBuildProviders(System.Web.VirtualPath 
>>> virtualPath, System.String virtualDir, 
>>> System.Collections.Generic.Dictionary`2 vpCache, BuildKind ByRef 
>>> kind, System.String ByRef assemblyBaseName)
>>>    at 
>>> System.Web.Compilation.BuildManager.BuildAssembly(System.Web.VirtualPath 
>>> virtualPath)
>>>    at 
>>> System.Web.Compilation.BuildManager.GetCompiledType(System.String 
>>> virtualPath)
>>>    at 
>>> System.Web.Compilation.AspComponentFoundry+TagNameFoundry.LoadType()
>>>    at 
>>> System.Web.Compilation.AspComponentFoundry+TagNameFoundry.GetType(System.String 
>>> componentName, System.String ByRef source, System.String ByRef ns)
>>>    at 
>>> System.Web.Compilation.AspComponentFoundry.CreateComponent(System.Web.Compilation.Foundry 
>>> foundry, System.String tagName, System.String prefix, System.String tag)
>>>    at 
>>> System.Web.Compilation.AspComponentFoundry.GetComponent(System.String 
>>> tagName)
>>>    at System.Web.UI.RootBuilder.GetChildControlType(System.String 
>>> tagName, IDictionary attribs)
>>>    at System.Web.UI.ControlBuilder.CreateSubBuilder(System.String 
>>> tagid, System.Collections.Hashtable atts, System.Type childType, 
>>> System.Web.UI.TemplateParser parser, ILocation location)
>>>    at System.Web.Compilation.AspGenerator.ProcessTag(ILocation 
>>> location, System.String tagid, System.Web.Compilation.TagAttributes 
>>> atts, TagType tagtype, Boolean ByRef ignored)
>>>    at System.Web.Compilation.AspGenerator.TagParsed(ILocation 
>>> location, TagType tagtype, System.String tagid, 
>>> System.Web.Compilation.TagAttributes attributes)
>>>    at System.Web.Compilation.AspParser.OnTagParsed(TagType tagtype, 
>>> System.String id, System.Web.Compilation.TagAttributes attributes)
>>>    at System.Web.Compilation.AspParser.Parse()
>>>    at System.Web.Compilation.AspGenerator.Parse(System.IO.TextReader 
>>> reader, System.String filename, Boolean doInitParser)
>>>    at System.Web.Compilation.GenericBuildProvider`1.Parse()
>>>    at 
>>> System.Web.Compilation.GenericBuildProvider`1.get_CodeCompilerType()
>>>    at 
>>> System.Web.Compilation.BuildManager.GetCodeDomProviderType(System.Web.Compilation.BuildProvider 
>>> provider)
>>>    at 
>>> System.Web.Compilation.BuildManager+BuildItem..ctor(System.Web.Compilation.BuildProvider 
>>> provider)
>>>    at 
>>> System.Web.Compilation.BuildManager.LoadBuildProviders(System.Web.VirtualPath 
>>> virtualPath, System.String virtualDir, 
>>> System.Collections.Generic.Dictionary`2 vpCache, BuildKind ByRef 
>>> kind, System.String ByRef assemblyBaseName)
>>>    at 
>>> System.Web.Compilation.BuildManager.BuildAssembly(System.Web.VirtualPath 
>>> virtualPath)
>>>    at 
>>> System.Web.Compilation.BuildManager.GetCompiledType(System.String 
>>> virtualPath)
>>>    at 
>>> System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(System.String 
>>> virtualPath, System.Type requiredBaseType)
>>>    at System.Web.UI.PageParser.GetCompiledPageInstance(System.String 
>>> virtualPath, System.String inputFile, System.Web.HttpContext context)
>>>    at 
>>> System.Web.UI.PageHandlerFactory.GetHandler(System.Web.HttpContext 
>>> context, System.String requestType, System.String url, System.String 
>>> path)
>>>    at System.Web.HttpApplication.GetHandler(System.Web.HttpContext 
>>> context, System.String url, Boolean ignoreContextHandler)
>>>    at System.Web.HttpApplication.GetHandler(System.Web.HttpContext 
>>> context, System.String url)
>>>    at System.Web.HttpApplication+<Pipeline>c__Iterator2.MoveNext()
>>>    at System.Web.HttpApplication.Tick()
>>>    at System.Web.HttpApplication.Start(System.Object x)
>>>    at 
>>> System.Web.HttpApplication.System.Web.IHttpHandler.ProcessRequest(System.Web.HttpContext 
>>> context)
>>>    at System.Web.HttpRuntime.Process(System.Web.HttpWorkerRequest req)
>>>    at System.Web.HttpRuntime.RealProcessRequest(System.Object o)
>>>    at 
>>> System.Web.HttpRuntime.ProcessRequest(System.Web.HttpWorkerRequest wr)
>>>    at Mono.WebServer.MonoWorkerRequest.ProcessRequest()
>>>    at 
>>> Mono.WebServer.BaseApplicationHost.ProcessRequest(Mono.WebServer.MonoWorkerRequest 
>>> mwr)
>>>    at Mono.WebServer.XSPApplicationHost.ProcessRequest(Int32 reqId, 
>>> Int64 localEPAddr, Int32 localEPPort, Int64 remoteEPAdds, Int32 
>>> remoteEPPort, System.String verb, System.String path, System.String 
>>> queryString, System.String protocol, System.Byte[] inputBuffer, 
>>> System.String redirect, IntPtr socket, Mono.WebServer.SslInformations 
>>> ssl)
>>>    at Mono.WebServer.XSPWorker.RunInternal(System.Object state)
>>> =============================================================================== 
>>>
>>>
>>> As you can see there is deadlock between 
>>> System.Web.Compilation.BuildManager.AddToCache (thread 2, second 
>>> item) and System.Web.Compilation.BuildManager.GenerateAssembly (both 
>>> using lock (buildCacheLock)) and between System.Web.Caching.Cache.Add 
>>> and System.Web.Caching.Cache.InvokePrivateCallbacks() (both using 
>>> lock(cache))
>>>
>>> I am curious if someone is working on this bug (is this known bug?) 
>>> or I should try to fix it myself?
>>>
>>> Best regards,
>>> Ivan
>>>
>> _______________________________________________
>> Mono-devel-list mailing list
>> Mono-devel-list at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>>
> 
> 


More information about the Mono-devel-list mailing list