moonpyk / mvcdonutcaching

ASP.NET MVC Extensible Donut Caching brings donut caching to ASP.NET MVC 3 and later. The code allows you to cache all of your page apart from one or more Html.Actions which can be executed every request. Perfect for user specific content.
https://github.com/moonpyk/mvcdonutcaching
MIT License
142 stars 49 forks source link

Intermittent Object reference not set to an instance of an object #19

Closed YodasMyDad closed 10 years ago

YodasMyDad commented 10 years ago

I am seeing this quite often on one of my sites. Its a multi-store implementation, so multiple stores running on different urls all from a single app.

I get the following error intermittently, from once a day up to 4 or 5?

Server Error in '/' Application.
Object reference not set to an instance of an object.
Description: Object reference not set to an instance of an object. 

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error: 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 
[NullReferenceException: Object reference not set to an instance of an object.]
   DevTrends.MvcDonutCaching.KeyGenerator.GenerateKey(ControllerContext context, CacheSettings cacheSettings) in c:\Users\moonpyk\Documents\Visual Studio 2012\Projects\mvcdonutcaching\DevTrends.MvcDonutCaching\KeyGenerator.cs:43
   DevTrends.MvcDonutCaching.DonutOutputCacheAttribute.ExecuteCallback(ControllerContext context, Boolean hasErrors) in c:\Users\moonpyk\Documents\Visual Studio 2012\Projects\mvcdonutcaching\DevTrends.MvcDonutCaching\DonutOutputCacheAttribute.cs:268
   System.Web.Mvc.ControllerActionInvoker.InvokeExceptionFilters(ControllerContext controllerContext, IList`1 filters, Exception exception) +169
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +727005
   System.Web.Mvc.Controller.ExecuteCore() +158
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +333
   System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +61
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +14
   System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +51
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +605
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +287
moonpyk commented 10 years ago

Strange issue, thanks for the stack trace, what version are you using ?

YodasMyDad commented 10 years ago

As far as I'm aware the latest version. If I check the properties on the DLL it says product version 1.2.3

capture

moonpyk commented 10 years ago

I have the exact line code number, I should be able to guess what is null and shouldn't be. Caching should at least not work, not make the app crash.

YodasMyDad commented 10 years ago

That would be great. What's the likely timeframe to get this added? I'd like to update it on the site :+1:

YodasMyDad commented 10 years ago

Sorry to hassle again. I'm just wondering if this is something I could add in and build locally? As this is happening quite a lot now, I'm concerned I'm going to have to remove it if I can't put in this patch.

moonpyk commented 10 years ago

Could you try http://www.nuget.org/packages/MvcDonutCaching/1.3.0-beta1 and tell me if this solved the issue ? In that case i'll put that version as stable.

YodasMyDad commented 10 years ago

Ok I'll give it a try, but that link says it was last updated on Friday, November 08 2013??

moonpyk commented 10 years ago

Yeah, quite a lot of work has been done during that period, and external events forced me to put everything on hiatus, I think your bug is already fixed...

YodasMyDad commented 10 years ago

Ok no problem :+1: Have just added it and uploaded to the website, I'll let you know if it falls over again. Thanks for the reply.

alb-xss commented 10 years ago

Hi @moonpyk I'm having a lot of these errors lately, I'm not sure why. I also have multiple subdomains running with a single webapp like the op, so it probably has something to do with that. I'm using the latest stable version (1.2.3) and apparently you already managed to trap the error and invalidate the cache. Can you please release a minor bug fix version (1.2.4) nuget package for this?

Here's the stack trace anyway, in case it may be useful:

Exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at DevTrends.MvcDonutCaching.KeyGenerator.GenerateKey(ControllerContext context, CacheSettings cacheSettings)
   at DevTrends.MvcDonutCaching.DonutOutputCacheAttribute.ExecuteCallback(ControllerContext context, Boolean hasErrors)
   at DevTrends.MvcDonutCaching.DonutOutputCacheAttribute.OnException(ExceptionContext filterContext)
   at System.Web.Mvc.ControllerActionInvoker.InvokeExceptionFilters(ControllerContext controllerContext, IList`1 filters, Exception exception)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass25.<BeginInvokeAction>b__1e(AsyncCallback asyncCallback, Object asyncState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.Begin(AsyncCallback callback, Object state, Int32 timeout)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext, String actionName, AsyncCallback callback, Object state)
   at System.Web.Mvc.Controller.<>c__DisplayClass1d.<BeginExecuteCore>b__17(AsyncCallback asyncCallback, Object asyncState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.Begin(AsyncCallback callback, Object state, Int32 timeout)
   at System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback callback, Object state)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.Begin(AsyncCallback callback, Object state, Int32 timeout)
   at System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state)
   at System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state)
   at System.Web.Mvc.MvcHandler.<>c__DisplayClass8.<BeginProcessRequest>b__2(AsyncCallback asyncCallback, Object asyncState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.Begin(AsyncCallback callback, Object state, Int32 timeout)
   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)

Thanks

YodasMyDad commented 10 years ago

Randomly I got this the error again the other day, it's no where near as frequent as it was (I'm using that 1.3.0beta you linked above). I'm also using this on a single webapp with multiple domains.

moonpyk commented 10 years ago

@leen3o the rc is out, I brought a few more fixes

moonpyk commented 10 years ago

@ejjpi you should try the rc

alb-xss commented 10 years ago

Thanks, I will.

YodasMyDad commented 10 years ago

Will try it now thanks. Will let you know if it still happens.

alb-xss commented 10 years ago

It's still happening even with the RC. I did some digging and I found that all the crashing requests are coming from a crawler bot. As a workaround, I blocked all the specific crawler requests and it solved the problem, but I still have no idea why it's crashing. I had a look at HTTP headers but I didn't see anything fancy, except for some random spam keywords with an url sent in the form.

Here's the elmah error report (I did some obfuscating of sensible data):

<error
  application="/LM/W3SVC/20/ROOT"
  type="System.NullReferenceException"
  message="Object reference not set to an instance of an object."
  source="DevTrends.MvcDonutCaching"
  detail="System.NullReferenceException: Object reference not set to an instance of an object.&#xD;&#xA;   at DevTrends.MvcDonutCaching.KeyGenerator.GenerateKey(ControllerContext context, CacheSettings cacheSettings)&#xD;&#xA;   at DevTrends.MvcDonutCaching.DonutOutputCacheAttribute.ExecuteCallback(ControllerContext context, Boolean hasErrors)&#xD;&#xA;   at DevTrends.MvcDonutCaching.DonutOutputCacheAttribute.OnException(ExceptionContext filterContext)&#xD;&#xA;   at System.Web.Mvc.ControllerActionInvoker.InvokeExceptionFilters(ControllerContext controllerContext, IList`1 filters, Exception exception)&#xD;&#xA;   at System.Web.Mvc.Async.AsyncControllerActionInvoker.&lt;&gt;c__DisplayClass25.&lt;BeginInvokeAction&gt;b__1e(AsyncCallback asyncCallback, Object asyncState)&#xD;&#xA;   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.Begin(AsyncCallback callback, Object state, Int32 timeout)&#xD;&#xA;   at System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext, String actionName, AsyncCallback callback, Object state)&#xD;&#xA;   at System.Web.Mvc.Controller.&lt;&gt;c__DisplayClass1d.&lt;BeginExecuteCore&gt;b__17(AsyncCallback asyncCallback, Object asyncState)&#xD;&#xA;   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.Begin(AsyncCallback callback, Object state, Int32 timeout)&#xD;&#xA;   at System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback callback, Object state)&#xD;&#xA;   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.Begin(AsyncCallback callback, Object state, Int32 timeout)&#xD;&#xA;   at System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state)&#xD;&#xA;   at System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state)&#xD;&#xA;   at System.Web.Mvc.MvcHandler.&lt;&gt;c__DisplayClass8.&lt;BeginProcessRequest&gt;b__2(AsyncCallback asyncCallback, Object asyncState)&#xD;&#xA;   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.Begin(AsyncCallback callback, Object state, Int32 timeout)&#xD;&#xA;   at System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state)&#xD;&#xA;   at System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state)&#xD;&#xA;   at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)&#xD;&#xA;   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()&#xD;&#xA;   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously)"
  time="2014-06-29T15:59:49.5248339Z">
  <serverVariables>
    <item
      name="ALL_HTTP">
      <value
        string="HTTP_CONNECTION:close&#xD;&#xA;HTTP_CONTENT_LENGTH:182&#xD;&#xA;HTTP_CONTENT_TYPE:application/x-www-form-urlencoded&#xD;&#xA;HTTP_ACCEPT:text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1&#xD;&#xA;HTTP_ACCEPT_ENCODING:gzip, deflate&#xD;&#xA;HTTP_ACCEPT_LANGUAGE:zh;q=0.9,en;q=0.8&#xD;&#xA;HTTP_HOST:blablabla.com&#xD;&#xA;HTTP_USER_AGENT:Mozilla/5.0 (compatible; EasouSpider; +http://www.easou.com/search/spider.html)&#xD;&#xA;HTTP_REFER:http://blablabla.com/&#xD;&#xA;" />
    </item>
    <item
      name="ALL_RAW">
      <value
        string="Connection: close&#xD;&#xA;Content-Length: 182&#xD;&#xA;Content-Type: application/x-www-form-urlencoded&#xD;&#xA;Accept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1&#xD;&#xA;Accept-Encoding: gzip, deflate&#xD;&#xA;Accept-Language: zh;q=0.9,en;q=0.8&#xD;&#xA;Host: blablabla.com&#xD;&#xA;User-Agent: Mozilla/5.0 (compatible; EasouSpider; +http://www.easou.com/search/spider.html)&#xD;&#xA;Refer: http://blablabla.com/&#xD;&#xA;" />
    </item>
    <item
      name="APPL_MD_PATH">
      <value
        string="/LM/W3SVC/20/ROOT" />
    </item>
    <item
      name="AUTH_TYPE">
      <value
        string="" />
    </item>
    <item
      name="AUTH_USER">
      <value
        string="" />
    </item>
    <item
      name="AUTH_PASSWORD">
      <value
        string="" />
    </item>
    <item
      name="LOGON_USER">
      <value
        string="" />
    </item>
    <item
      name="REMOTE_USER">
      <value
        string="" />
    </item>
    <item
      name="CERT_COOKIE">
      <value
        string="" />
    </item>
    <item
      name="CERT_FLAGS">
      <value
        string="" />
    </item>
    <item
      name="CERT_ISSUER">
      <value
        string="" />
    </item>
    <item
      name="CERT_KEYSIZE">
      <value
        string="" />
    </item>
    <item
      name="CERT_SECRETKEYSIZE">
      <value
        string="" />
    </item>
    <item
      name="CERT_SERIALNUMBER">
      <value
        string="" />
    </item>
    <item
      name="CERT_SERVER_ISSUER">
      <value
        string="" />
    </item>
    <item
      name="CERT_SERVER_SUBJECT">
      <value
        string="" />
    </item>
    <item
      name="CERT_SUBJECT">
      <value
        string="" />
    </item>
    <item
      name="CONTENT_LENGTH">
      <value
        string="182" />
    </item>
    <item
      name="CONTENT_TYPE">
      <value
        string="application/x-www-form-urlencoded" />
    </item>
    <item
      name="GATEWAY_INTERFACE">
      <value
        string="CGI/1.1" />
    </item>
    <item
      name="HTTPS">
      <value
        string="off" />
    </item>
    <item
      name="HTTPS_KEYSIZE">
      <value
        string="" />
    </item>
    <item
      name="HTTPS_SECRETKEYSIZE">
      <value
        string="" />
    </item>
    <item
      name="HTTPS_SERVER_ISSUER">
      <value
        string="" />
    </item>
    <item
      name="HTTPS_SERVER_SUBJECT">
      <value
        string="" />
    </item>
    <item
      name="INSTANCE_ID">
      <value
        string="20" />
    </item>
    <item
      name="INSTANCE_META_PATH">
      <value
        string="/LM/W3SVC/20" />
    </item>
    <item
      name="QUERY_STRING">
      <value
        string="" />
    </item>
    <item
      name="REMOTE_ADDR">
      <value
        string="183.60.214.59" />
    </item>
    <item
      name="REMOTE_HOST">
      <value
        string="183.60.214.59" />
    </item>
    <item
      name="REMOTE_PORT">
      <value
        string="36890" />
    </item>
    <item
      name="REQUEST_METHOD">
      <value
        string="GET" />
    </item>
    <item
      name="SERVER_NAME">
      <value
        string="blablabla.com" />
    </item>
    <item
      name="SERVER_PORT">
      <value
        string="80" />
    </item>
    <item
      name="SERVER_PORT_SECURE">
      <value
        string="0" />
    </item>
    <item
      name="SERVER_PROTOCOL">
      <value
        string="HTTP/1.1" />
    </item>
    <item
      name="SERVER_SOFTWARE">
      <value
        string="Microsoft-IIS/8.0" />
    </item>
    <item
      name="HTTP_CONNECTION">
      <value
        string="close" />
    </item>
    <item
      name="HTTP_CONTENT_LENGTH">
      <value
        string="182" />
    </item>
    <item
      name="HTTP_CONTENT_TYPE">
      <value
        string="application/x-www-form-urlencoded" />
    </item>
    <item
      name="HTTP_ACCEPT">
      <value
        string="text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1" />
    </item>
    <item
      name="HTTP_ACCEPT_ENCODING">
      <value
        string="gzip, deflate" />
    </item>
    <item
      name="HTTP_ACCEPT_LANGUAGE">
      <value
        string="zh;q=0.9,en;q=0.8" />
    </item>
    <item
      name="HTTP_HOST">
      <value
        string="blablabla.com" />
    </item>
    <item
      name="HTTP_USER_AGENT">
      <value
        string="Mozilla/5.0 (compatible; EasouSpider; +http://www.easou.com/search/spider.html)" />
    </item>
    <item
      name="HTTP_REFER">
      <value
        string="http://blablabla.com/" />
    </item>
  </serverVariables>
  <form>
    <item
      name="">
      <value
        string="some spam keywords with an url" />
    </item>
  </form>
</error>

Maybe somebody else is able to find what's going on!

tubededentifrice commented 10 years ago

Same issue, different line here, probably a duplicate: https://github.com/moonpyk/mvcdonutcaching/issues/26