kyleleeli / elmah

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

Stack trace highlighting doesn't work for Mono #320

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The nice stack trace syntax highlighting doesn't work correctly for stack 
traces produced by Mono. I'm assuming the regular expression to match the stack 
frames just needs to be tweaked a bit.

Here is an example stack trace from Mono:

System.Web.HttpException: The controller for path '/helloworld' was not found 
or does not implement IController.
  at System.Web.Mvc.DefaultControllerFactory.GetControllerInstance (System.Web.Routing.RequestContext requestContext, System.Type controllerType) [0x00000] in <filename unknown>:0 
  at System.Web.Mvc.DefaultControllerFactory.CreateController (System.Web.Routing.RequestContext requestContext, System.String controllerName) [0x00000] in <filename unknown>:0 
  at System.Web.Mvc.MvcHandler.ProcessRequestInit (System.Web.HttpContextBase httpContext, IController& controller, IControllerFactory& factory) [0x00000] in <filename unknown>:0 
  at System.Web.Mvc.MvcHandler.BeginProcessRequest (System.Web.HttpContextBase httpContext, System.AsyncCallback callback, System.Object state) [0x00000] in <filename unknown>:0 
  at System.Web.Mvc.MvcHandler.BeginProcessRequest (System.Web.HttpContext httpContext, System.AsyncCallback callback, System.Object state) [0x00000] in <filename unknown>:0 
  at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest (System.Web.HttpContext context, System.AsyncCallback cb, System.Object extraData) [0x00000] in <filename unknown>:0 
  at System.Web.HttpApplication+<Pipeline>c__Iterator3.MoveNext () [0x00000] in <filename unknown>:0 
  at System.Web.HttpApplication.Tick () [0x00000] in <filename unknown>:0 

Here is how the same stack trace looks from Microsoft .NET:

System.Web.HttpException (0x80004005): The controller for path '/helloworld' 
was not found or does not implement IController.
   at System.Web.Mvc.DefaultControllerFactory.GetControllerInstance((RequestContext requestContext, Type controllerType))
   at System.Web.Mvc.DefaultControllerFactory.CreateController((RequestContext requestContext, String controllerName))
   at System.Web.Mvc.MvcHandler.ProcessRequestInit((HttpContextBase httpContext, IController& controller, IControllerFactory& factory))
   at System.Web.Mvc.MvcHandler.BeginProcessRequest((HttpContextBase httpContext, AsyncCallback callback, Object state))
   at System.Web.Mvc.MvcHandler.BeginProcessRequest((HttpContext httpContext, AsyncCallback callback, Object state))
   at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest((HttpContext context, AsyncCallback cb, Object extraData))
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute(())
   at System.Web.HttpApplication.ExecuteStep((IExecutionStep step, Boolean& completedSynchronously))

Original issue reported on code.google.com by daniel@d15.biz on 15 Dec 2012 at 11:12

GoogleCodeExporter commented 9 years ago
This updated regular expression for ErrorDetailPage seems to work. I haven't 
tested it in the ELMAH code yet but I've tried it in an online regex tester 
(RegexHero) and it seems to work with both Microsoft stack traces and Mono 
stack traces:

                ^
                \s*
                \w+ \s+ 
                (?<type> .+ ) \.
                (?<method> .+? ) 
                (?<params> \( (?<params> .*? ) \) )
                (
                  (?# Microsoft .NET stack traces ) 
                  ( \s+ 
                    \w+ \s+ 
                    (?<file> [a-z] \: .+? ) 
                    \: \w+ \s+ 
                    (?<line> [0-9]+ ) \p{P}? ) 
                  | 

                  (?# Mono stack traces ) 
                  ( \s+
                    \[0x\d+\] \s in \s 
                    <(?<file> [^>]+ )>
                    :(?<line> [0-9]+ )
                  )
                )?
                \s*
                $

Original comment by daniel@d15.biz on 15 Dec 2012 at 11:34

GoogleCodeExporter commented 9 years ago
Thanks for reporting and helping out with a Regex that works for both 
platforms. Just curious, how are you getting double parentheses in your second, 
Microsoft .NET, stack trace?
IExecutionStep.Execute(())

Original comment by azizatif on 16 Dec 2012 at 3:35

GoogleCodeExporter commented 9 years ago
To be honest, I have no idea. I just copied the message straight from ELMAH.

Original comment by daniel@d15.biz on 16 Dec 2012 at 9:55

GoogleCodeExporter commented 9 years ago
That's strange... I tried replicating the double parentheses and it's not 
happening any more? I deleted the old database while doing some other dev work 
so don't have a copy of the data with the double parentheses. Oh well.

Original comment by daniel@d15.biz on 17 Dec 2012 at 11:04

GoogleCodeExporter commented 9 years ago
Here's one I got today that was highlighted weirdly:

System.Exception: Couldn't get social share count for Twitter ---> 
System.Net.WebException: libMonoPosixHelper.so ---> 
System.DllNotFoundException: libMonoPosixHelper.so
  at (wrapper managed-to-native) System.IO.Compression.DeflateStream:CreateZStream ((System.IO.Compression.CompressionModeboolSystem.IO.Compression.DeflateStream/UnmanagedReadOrWriteintptr))
  at System.IO.Compression.DeflateStream..ctor (System.IO.Stream compressedStream, CompressionMode mode, Boolean leaveOpen, Boolean gzip) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.IO.Compression.DeflateStream:.ctor ((System.IO.StreamSystem.IO.Compression.CompressionModeboolbool))
  at System.IO.Compression.GZipStream..ctor (System.IO.Stream compressedStream, CompressionMode mode, Boolean leaveOpen) [0x00000] in <filename unknown>:0 
  at System.IO.Compression.GZipStream..ctor (System.IO.Stream compressedStream, CompressionMode mode) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.IO.Compression.GZipStream:.ctor ((System.IO.StreamSystem.IO.Compression.CompressionMode))
  at System.Net.HttpWebResponse..ctor (System.Uri uri, System.String method, System.Net.WebConnectionData data, System.Net.CookieContainer container) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Net.HttpWebResponse:.ctor ((System.UristringSystem.Net.WebConnectionDataSystem.Net.CookieContainer))
  at System.Net.HttpWebRequest.SetResponseData (System.Net.WebConnectionData data) [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 
  at System.Net.HttpWebRequest.GetResponse () [0x00000] in <filename unknown>:0 
  at ServiceStack.Text.WebRequestExtensions.GetStringFromUrl (System.String url, System.String acceptContentType, System.Action`1 responseFilter) [0x00000] in <filename unknown>:0 
  at ServiceStack.Text.WebRequestExtensions.GetJsonFromUrl (System.String url, System.Action`1 responseFilter) [0x00000] in <filename unknown>:0 
  at Daniel15.Web.Services.Social.Twitter.GetShareCount (Daniel15.Web.Models.Blog.PostSummaryModel post, System.String url, System.String shortUrl) [0x00000] in <filename unknown>:0 
  at Daniel15.Web.Services.Social.SocialManager.ShareCounts (Daniel15.Web.Models.Blog.PostSummaryModel post, System.String url, System.String shortUrl) [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---

Screenshot of how it was highlighted by ELMAH is attached.

Original comment by daniel@d15.biz on 19 Dec 2012 at 11:59

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for the follow ups. I was going through the regular expression yesterday 
and might have spotted where the double parentheses might be coming from. 
Strange that I have never come across it. Which version are you using and is 
that screenshot coming from ELMAH running on the Mono platform?

Original comment by azizatif on 19 Dec 2012 at 6:59

GoogleCodeExporter commented 9 years ago
Yes, the screenshot is coming from ELMAH running on Mono. I'm using Mono 3.0.2 
(.NET Framework 4.0) and ELMAH 1.2 SP2 (installed via NuGet).

Original comment by daniel@d15.biz on 20 Dec 2012 at 7:31

GoogleCodeExporter commented 9 years ago
In that case, I have a feeling that Regex on Mono might be behaving slightly 
differently and is capturing the extra parentheses (yet not always?) but I'll 
double-check that against stack traces in existing logs and on Microsoft .NET 
Framework.

Original comment by azizatif on 20 Dec 2012 at 7:38

GoogleCodeExporter commented 9 years ago
Yeah I've heard the regex engine in Mono sometimes does things a bit 
differently so it could be hitting some edge case in its engine.

I'm happy to beta test any changes if you like :)

Original comment by daniel@d15.biz on 20 Dec 2012 at 8:16

GoogleCodeExporter commented 9 years ago

Original comment by azizatif on 23 Dec 2012 at 12:19

GoogleCodeExporter commented 9 years ago
This issue was closed by revision 4772b05acf51.

Original comment by azizatif on 23 Dec 2012 at 12:40

GoogleCodeExporter commented 9 years ago
> I'm happy to beta test any changes if you like :)

Let me know how that goes :)

Original comment by azizatif on 23 Dec 2012 at 12:41

GoogleCodeExporter commented 9 years ago
The latest version of ELMAH crashes when I try to go to elmah.axd - Looks like 
HttpBrowserCapabilitiesBase.CreateHtmlTextWriter isn't implemented in Mono:

System.NotImplementedException
The requested feature is not implemented.
 at System.Web.HttpBrowserCapabilitiesWrapper.CreateHtmlTextWriter (System.IO.TextWriter w) [0x00000] in <filename unknown>:0 
  at Elmah.SpeedBar+<>c__DisplayClass3.<Render>b__1 (System.IO.TextWriter writer) [0x00000] in <filename unknown>:0 
  at Elmah.HelperResult.WriteTo (System.IO.TextWriter writer) [0x00000] in <filename unknown>:0 
  at Elmah.HelperResult.ToHtmlString () [0x00000] in <filename unknown>:0 
  at Elmah.WebTemplateBase.Write (System.Object value) [0x00000] in <filename unknown>:0 
  at Elmah.MasterPage.Execute () [0x00000] in <filename unknown>:0 
  at Elmah.RazorTemplateBase.TransformText () [0x00000] in <filename unknown>:0 
  at Elmah.WebTemplateBase.TransformText () [0x00000] in <filename unknown>:0 
  at Elmah.RazorTemplateBase.TransformText () [0x00000] in <filename unknown>:0 
  at Elmah.WebTemplateBase.TransformText () [0x00000] in <filename unknown>:0 
  at Elmah.WebTemplateBase.ProcessRequest () [0x00000] in <filename unknown>:0 
  at Elmah.WebTemplateBase.System.Web.IHttpHandler.ProcessRequest (System.Web.HttpContext context) [0x00000] in <filename unknown>:0 
  at System.Web.HttpApplication+<Pipeline>c__Iterator3.MoveNext () [0x00000] in <filename unknown>:0 
  at System.Web.HttpApplication.Tick () [0x00000] in <filename unknown>:0 

Should I raise this as a separate bug?

Original comment by daniel@d15.biz on 23 Dec 2012 at 1:18

GoogleCodeExporter commented 9 years ago
I "fixed" the above issue by not using browser.CreateHtmlTextWriter - That is, 
changing this:
return Render(browser.CreateHtmlTextWriter, items);

To this:
return Render((Func<TextWriter, HtmlTextWriter>)null, items);

In SpeedBar.cs. Not sure if this may break something, but it appears to be 
working. And the syntax highlighting is working too. Screenshot attached :)

Original comment by daniel@d15.biz on 23 Dec 2012 at 1:28

Attachments:

GoogleCodeExporter commented 9 years ago
I just found an error that appears to get it stuck in a very long loop. Takes a 
long time to render the page in ELMAH (MiniProfiler says 17 seconds on Windows 
and 21 seconds on Linux Mono) and the worker process uses 100% CPU the whole 
time. Happens on both Microsoft .NET and Mono. Here's the stack trace causing 
the problem:

System.Web.HttpRequestValidationException: A potentially dangerous 
Request.QueryString value was detected from the client (test="<p>asd").
  at System.Web.HttpRequest.ThrowValidationException (System.String name, System.String key, System.String value) [0x00040] in /usr/local/src/mono-3.0.2/mcs/class/System.Web/System.Web/HttpRequest.cs:1723 
  at System.Web.HttpRequest.ValidateString (System.String key, System.String value, RequestValidationSource source) [0x00019] in /usr/local/src/mono-3.0.2/mcs/class/System.Web/System.Web/HttpRequest.cs:1734 
  at Microsoft.Web.Infrastructure.DynamicValidationHelper.LazyWebROCollection.Validate (System.String key, System.String value) [0x0000d] in /usr/local/src/mono-3.0.2/mcs/class/Microsoft.Web.Infrastructure/Microsoft.Web.Infrastructure.DynamicValidationHelper/LazyWebROCollection.cs:134 
  at Microsoft.Web.Infrastructure.DynamicValidationHelper.LazyWebROCollection.Get (System.String name) [0x00000] in /usr/local/src/mono-3.0.2/mcs/class/Microsoft.Web.Infrastructure/Microsoft.Web.Infrastructure.DynamicValidationHelper/LazyWebROCollection.cs:86 
  at System.Collections.Specialized.NameValueCollection.get_Item (System.String name) [0x00000] in /usr/local/src/mono-3.0.2/mcs/class/System/System.Collections.Specialized/NameValueCollection.cs:117 
  at System.Web.HttpRequest.ValidateNameValueCollection (System.String name, System.Collections.Specialized.NameValueCollection coll) [0x00018] in /usr/local/src/mono-3.0.2/mcs/class/System.Web/System.Web/HttpRequest.cs:1643 
  at System.Web.HttpRequest.get_QueryString () [0x0005c] in /usr/local/src/mono-3.0.2/mcs/class/System.Web/System.Web/HttpRequest.cs:1183 
  at System.Web.HttpRequestWrapper.get_QueryString () [0x00000] in /usr/local/src/mono-3.0.2/mcs/class/System.Web.Abstractions/System.Web/HttpRequestWrapper.cs:186 
  at System.Web.Mvc.QueryStringValueProvider..ctor (System.Web.Mvc.ControllerContext controllerContext, IUnvalidatedRequestValues unvalidatedValues) [0x00000] in <filename unknown>:0 
  at System.Web.Mvc.QueryStringValueProviderFactory.GetValueProvider (System.Web.Mvc.ControllerContext controllerContext) [0x00000] in <filename unknown>:0 
  at System.Web.Mvc.ValueProviderFactoryCollection+<>c__DisplayClassc.<GetValueProvider>b__7 (System.Web.Mvc.ValueProviderFactory factory) [0x00000] in <filename unknown>:0 
  at System.Linq.Enumerable+<CreateSelectIterator>c__Iterator1C`2[System.Web.Mvc.ValueProviderFactory,<>f__AnonymousType2`2[System.Web.Mvc.ValueProviderFactory,System.Web.Mvc.IValueProvider]].MoveNext () [0x00059] in /usr/local/src/mono-3.0.2/mcs/class/System.Core/System.Linq/Enumerable.cs:2269 
  at System.Linq.Enumerable+<CreateWhereIterator>c__Iterator2A`1[<>f__AnonymousType2`2[System.Web.Mvc.ValueProviderFactory,System.Web.Mvc.IValueProvider]].MoveNext () [0x0006f] in /usr/local/src/mono-3.0.2/mcs/class/System.Core/System.Linq/Enumerable.cs:3115 
  at System.Linq.Enumerable+<CreateSelectIterator>c__Iterator1C`2[<>f__AnonymousType2`2[System.Web.Mvc.ValueProviderFactory,System.Web.Mvc.IValueProvider],System.Web.Mvc.IValueProvider].MoveNext () [0x00059] in /usr/local/src/mono-3.0.2/mcs/class/System.Core/System.Linq/Enumerable.cs:2269 
  at System.Collections.Generic.List`1[System.Web.Mvc.IValueProvider].AddEnumerable (IEnumerable`1 enumerable) [0x00013] in /usr/local/src/mono-3.0.2/mcs/class/corlib/System.Collections.Generic/List.cs:134 
  at System.Collections.Generic.List`1[System.Web.Mvc.IValueProvider]..ctor (IEnumerable`1 collection) [0x0002f] in /usr/local/src/mono-3.0.2/mcs/class/corlib/System.Collections.Generic/List.cs:69 
  at System.Linq.Enumerable.ToList[IValueProvider] (IEnumerable`1 source) [0x00006] in /usr/local/src/mono-3.0.2/mcs/class/System.Core/System.Linq/Enumerable.cs:2951 
  at System.Web.Mvc.ValueProviderFactoryCollection.GetValueProvider (System.Web.Mvc.ControllerContext controllerContext) [0x00000] in <filename unknown>:0 
  at System.Web.Mvc.ControllerBase.get_ValueProvider () [0x00000] in <filename unknown>:0 
  at System.Web.Mvc.ControllerActionInvoker.GetParameterValue (System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ParameterDescriptor parameterDescriptor) [0x00000] in <filename unknown>:0 
  at System.Web.Mvc.ControllerActionInvoker.GetParameterValues (System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionDescriptor actionDescriptor) [0x00000] in <filename unknown>:0 
  at System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c__DisplayClass25.<BeginInvokeAction>b__1e (System.AsyncCallback asyncCallback, System.Object asyncState) [0x00000] in <filename unknown>:0

Original comment by daniel@d15.biz on 23 Dec 2012 at 1:42