mwrock / RequestReduce

Instantly makes your .net website faster by reducing the number and size of requests with almost no effort.
www.requestreduce.org
Apache License 2.0
228 stars 49 forks source link

The sum of offset and count is greater than the length of the buffer. Error #182

Closed harrysayari closed 12 years ago

harrysayari commented 12 years ago

Hi, I'm trying to use RequestReduce in my Umbraco project. it'll work fine when the code is in debug mode

web.config ==> compilation defaultLanguage="c#" debug="true" batch="false" targetFramework="4.0"

but if I change the debug attribute to false, I'll get this error:

Server Error in '/' Application.

The sum of offset and count is greater than the length of the buffer.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: The sum of offset and count is greater than the length of the buffer.

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:

[ArgumentException: The sum of offset and count is greater than the length of the buffer.] System.Web.HttpResponseStream.Write(Byte[] buffer, Int32 offset, Int32 count) +4042345 ClientDependency.Core.Module.ResponseFilterStream.Write(Byte[] buffer, Int32 offset, Int32 count) +167 RequestReduce.Module.ResponseFilter.DoTransform(Byte[] buffer, Int32& startTransformPosition) +215 RequestReduce.Module.ResponseFilter.HandleMatchingStartMatch(Byte b, Int32& i, Byte[] buffer, Int32& endTransformPosition, Int32& startTransformPosition) +131 RequestReduce.Module.ResponseFilter.Write(Byte[] buffer, Int32 offset, Int32 count) +183 System.Web.HttpWriter.FilterIntegrated(Boolean finalFiltering, IIS7WorkerRequest wr) +546 System.Web.HttpResponse.FilterOutput() +121 System.Web.CallFilterExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +105 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +252

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17379

I'm using .Net framework 4.0 RequestReduce version 1.8.32.0 and if try ?rrfilter=disabled page will work.

mwrock commented 12 years ago

Hmm. My guess is that your clientdependency response filter only kicks in in release mode and does not honor the offset and count arguments correctly. I've seen this happen a couple times with filters that assume they are free to work on the entire buffer.

I would review your clientdependency filter code.