ASP.Net application pool and KERNELBASE crashing, possible URL encoding problem

Hi
We’ve started seeing errors in the Event Viewer with w3wp.exe crashing. Here’re the relevant entries in eventvwr.

If you look at the 3rd item, you can see there’s a ArgumentOutOfRangeException and the URL has some spaces in them and not been properly encoded. Could this be the issue? How do I get JsonServiceClient to automatically encode query params?

1. An unhandled win32 exception occurred in w3wp.exe [13236]. Just-In-Time debugging this exception failed with the following error: Debugger could not be started because no user is logged on.
Check the documentation index for ‘Just-in-time debugging, errors’ for more information.

2. Faulting application name: w3wp.exe, version: 7.5.7601.17514, time stamp: 0x4ce7afa2
Faulting module name: KERNELBASE.dll, version: 6.1.7601.24441, time stamp: 0x5cb935a7
Exception code: 0xe0434352
Fault offset: 0x000000000000bdfd
Faulting process id: 0x33b4
Faulting application start time: 0x01d50f5f79670fc8
Faulting application path: c:\windows\system32\inetsrv\w3wp.exe
Faulting module path: C:\Windows\system32\KERNELBASE.dll
Report Id: c8fc32e8-7b52-11e9-846c-b8ca3a8a22a5

3. Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 21/05/2019 8:58:28 AM
Event time (UTC): 20/05/2019 10:58:28 PM
Event ID: 685b70f00a7143aab60729e8060987fd
Event sequence: 220
Event occurrence: 1
Event detail code: 0

Application information:
Application domain: /LM/W3SVC/1/ROOT/XVAXService-1-132028666811964808
Trust level: Full
Application Virtual Path: /XVAXService
Application Path: D:\Sites\CVAWebService\XVAXService\
Machine name: SYDSERVER1

Process information:
Process ID: 13236
Process name: w3wp.exe
Account name: NT3GWM01\svc_user_prd

Exception information:
Exception type: ArgumentOutOfRangeException
Exception message: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.Collections.ArrayList.get_Item(Int32 index)
at System.Web.HttpCookieCollection.Get(Int32 index)
at System.Web.HttpResponse.GenerateResponseHeadersForCookies()
at System.Web.HttpResponse.UpdateNativeResponse(Boolean sendHeaders)
at System.Web.HttpRuntime.FinishRequestNotification(IIS7WorkerRequest wr, HttpContext context, RequestNotificationStatus& status)

Request information:
Request URL: http://SYDSERVER1/XVAXService/legaldocument/?name=A BANK POSTBANK-XXX LIMITED-CSA&field=CounterpartyID
Request path: /XVAXService/legaldocument/
User host address: 10.16.203.20
User: NT3GWM01\csharpe
Is authenticated: True
Authentication Type: Negotiate
Thread account name: NT3GWM01\svc_user_prd

Thread information:
Thread ID: 10
Thread account name: NT3GWM01\svc_user_prd
Is impersonating: False
Stack trace: at System.Collections.ArrayList.get_Item(Int32 index)
at System.Web.HttpCookieCollection.Get(Int32 index)
at System.Web.HttpResponse.GenerateResponseHeadersForCookies()
at System.Web.HttpResponse.UpdateNativeResponse(Boolean sendHeaders)
at System.Web.HttpRuntime.FinishRequestNotification(IIS7WorkerRequest wr, HttpContext context, RequestNotificationStatus& status)

These StackTraces show that an ArgumentOutOfRangeException was thrown when accessing the HttpCookieCollection not the QueryString.

Are there any Inner Exceptions? I’m not seeing any indication the StackTrace originated from when ServiceStack accessed the HttpCookieCollection.

I can’t reproduce the error when the debugger is connected which is most annoying. All these messages are from eventvwr. There was a Warning in eventvwr.

A process serving application pool ‘XVAXService’ suffered a fatal communication error with the Windows Process Activation Service. The process id was ‘2604’. The data field contains the error number.

In our code we don’t access HttpCookieCollection and this is how we create the client.

_jsonclient = new JsonServiceClient(value) {Credentials = CredentialCache.DefaultCredentials, Timeout = TimeSpan.FromMinutes(30)};

I’m not seeing anywhere that this is related to ServiceStack, looking for the error message on Google yields a number of results with one of the suggested workarounds to Enable 32 Bit in IIS

Thanks @mythz
We’re not running IIS in a 32 bit OS so unfortunately that doesn’t help.

In our code we don’t access HttpCookieCollection and this is how we create the client. All webservice requests are via ServiceStack.

What’s suspicious is that the ArgumentOutOfRangeException always happens on that request path. And every time the query url doesn’t look like it has been encoded properly. Perhaps a red herring but how can I get ServiceStack to encode it properly?

That setting is for running 32 bit .dll’s in a 64 bit OS, given that’s the suggested workaround for the issue you’re having I would be trying that first.

Hi
Just tried switching to 32 bit and still having the same issue.

Not sure then, try out different solutions from Google.

Although unrelated to the Cookies Exception StackTrace you’re reporting, the Service Clients does already URL Encode its parameters, e.g. this request:

[Route("/hello")]
public partial class Hello
    : IReturn<HelloResponse>
{
    public virtual string Name { get; set; }
}

var response = client.Get(new Hello { Name = "Hello, World! 1 + 1 = 2" });

Already sends the expected HTTP Request / Response Headers:

HTTP Request

GET http://test.servicestack.net/hello?name=Hello%2C%20World%21%201%20%2B%201%20%3D%202 HTTP/1.1
Accept: application/json
User-Agent: ServiceStack .NET Client 5.51
Accept-Encoding: gzip,deflate
Host: test.servicestack.net
Connection: Keep-Alive

HTTP Response

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: application/json; charset=utf-8
Vary: Accept
Server: Microsoft-IIS/8.5
X-Powered-By: ServiceStack/5.00 Net45/Windows
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, PATCH, OPTIONS
Access-Control-Allow-Headers: Content-Type, Allow, Authorization, X-Args
Access-Control-Allow-Credentials: true
X-AspNet-Version: 4.0.30319
Set-Cookie: ss-id=Y9nDalCiTayydQAYQ8l0; path=/; HttpOnly
Set-Cookie: ss-pid=eQuAfkOZ1OEcEe32fNjA; expires=Sat, 21-May-2039 04:29:55 GMT; path=/; HttpOnly
X-Powered-By: ASP.NET
Date: Tue, 21 May 2019 04:29:55 GMT
Content-Length: 44

{"result":"Hello, Hello, World! 1 + 1 = 2!"}
```

Which you can verify by using a raw HTTP Traffic sniffer like Fiddler which lets you see the actual HTTP Request/Response sent.