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

Ivan Radovanovic rivanr at gmail.com
Sat Nov 7 14:18:17 EST 2009


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.
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 :-)

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
> 


More information about the Mono-devel-list mailing list