0

I am troubleshooting a legacy web service (asmx) that works to verify prices on partner websites. We have recently turned on the HttpWebRequest.AutomaticDecompression flag (DecompressionMethods.Deflate | DecompressionMethods.GZip) to hopefully speed up responses from some partners with large (650K+) pages. The code is old and proprietary so it is difficult to post an example so I will try and provide some implementation highlights:

  • Legacy .NET 3.5 ASMX web service running in a 4.5 app pool (allows TLS 1.2)
  • Each request (potentially) spawns multiple worker Threads; One for each partner to check.
  • Worker thread creates HttpWebRequest using automatic decompression and uses async methods to wait for partner responses:

    IAsyncResult r = (IAsyncResult)wreq.BeginGetResponse(new AsyncCallback(RespCallback), rs);

Since going into our test environment the result has been to get a few successful responses followed by a hard crash in the app pool. The mini dump shows a stack overflow (apparently) caused by the processing of a compressed stream:

System.dll!System.IO.Compression.OutputWindow.CopyTo(byte[] output, int offset, int length) Unknown
System.dll!System.IO.Compression.Inflater.Inflate(byte[] bytes, int offset, int length) Unknown
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown

... many more frames ...

PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)    Unknown
System.dll!System.IO.Compression.GZipStream.BeginRead(byte[] array, int offset, int count, System.AsyncCallback asyncCallback, object asyncState)   Unknown
System.dll!System.Net.GZipWrapperStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
PriceSvc.dll!ns.Price.ClientGetAsync.ReadCallBack(System.IAsyncResult asyncResult) Line 699 C#
System.dll!System.IO.Compression.DeflateStream.ReadCallback(System.IAsyncResult baseStreamResult)   Unknown
System.dll!System.Net.LazyAsyncResult.Complete(System.IntPtr userToken) Unknown
System.dll!System.Net.ContextAwareResult.CaptureOrComplete(ref System.Threading.ExecutionContext cachedContext, bool returnContext) Unknown
System.dll!System.Net.ContextAwareResult.FinishPostingAsyncOp(ref System.Net.CallbackClosure closure)   Unknown
System.dll!System.Net.Sockets.Socket.BeginReceive(byte[] buffer, int offset, int size, System.Net.Sockets.SocketFlags socketFlags, out System.Net.Sockets.SocketError errorCode, System.AsyncCallback callback, object state)   Unknown
System.dll!System.Net.Sockets.NetworkStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
System.dll!System.Net.PooledStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state)  Unknown
System.dll!System.Net.ConnectStream.BeginReadWithoutValidation(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state)    Unknown
System.dll!System.Net.ConnectStream.BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) Unknown
System.dll!System.IO.Compression.DeflateStream.ReadCallback(System.IAsyncResult baseStreamResult)   Unknown
System.dll!System.Net.LazyAsyncResult.Complete(System.IntPtr userToken) Unknown
mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)   Unknown
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)   Unknown
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Unknown
System.dll!System.Net.ContextAwareResult.Complete(System.IntPtr userToken)  Unknown
System.dll!System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(uint errorCode, uint numBytes, System.Threading.NativeOverlapped* nativeOverlapped)  Unknown
mscorlib.dll!System.Threading._IOCompletionCallback.PerformIOCompletionCallback(uint errorCode, uint numBytes, System.Threading.NativeOverlapped* pOVERLAP) Unknown
[Native to Managed Transition]  

My initial questions:

  1. Are there inherent problems running 3.5 apps in a 4.5 app pool? This issue does not repro when debugging using VS2008 with a 3.5 runtime.
  2. Is this symptomatic of a known issue (decompressing non-gzipped data or length mismatch?)... Seeing BeginReadWithoutValidation does not inspire confidence.

I realize this is vague so please let me know what kind of details I can add.

Kris Oye
  • 1,158
  • 14
  • 27
  • Does the issue reproduce when running in visual studio with a target framework of 4.5? – Botonomous Apr 12 '17 at 18:20
  • I am trying that out, now. – Kris Oye Apr 12 '17 at 18:41
  • I suppose PriceSvc.dll is your service? Could you try to find the line that calls `GZipWrapperStream.BeginRead`? Specifically, what is the size of the buffer? – Kevin Gosse Apr 12 '17 at 18:55
  • The GZip calls are happening under the covers inside the .NET framework itself through the use of AutomaticDecompression. I am going through all the little differences in our dev and test environments, now. – Kris Oye Apr 12 '17 at 19:00
  • Also, could you add a few more frames to better show the recursion? What is calling `GZipStream.BeginRead` in the "many more frames"? – Kevin Gosse Apr 12 '17 at 19:09
  • I can add more frames, sure. Our read buffer is only 1024 bytes btw (but is the same in both environments). – Kris Oye Apr 12 '17 at 19:16
  • 1
    I suspect the issue is with `ClientGetAsync.ReadCallBack`. You're calling `BeginRead` inside again and again until the end of the stream, blowing up the stack. There's a way to detect when `BeginRead` executed synchronously to avoid that, but to be honest I'm not too good with Begin/End APIs so I'm not sure what is the proper way to write this code. Ideally, since you're now targeting .NET 4.5, you could use the `ReadAsync` method instead, it will handle the logic for you. If there's no ReadAsync, you can use `Task.Factory.FromAsync` instead – Kevin Gosse Apr 12 '17 at 19:23
  • If you want to stick with Begin/End methods, see the "Stack dive" chapter here: https://blogs.msdn.microsoft.com/mjm/2005/05/04/asynchronous-programming-in-indigo/ – Kevin Gosse Apr 12 '17 at 19:28
  • I would much prefer to rewrite this circa 2001 code to use tasks. I don't even know why this code uses Begin/End since each request is on its own thread where blocking I/O wouldn't be an issue. – Kris Oye Apr 12 '17 at 19:32

0 Answers0