{"id":2352,"date":"2022-08-30T15:24:09","date_gmt":"2022-08-30T15:24:09","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/01\/05\/iis-crash-on-stack-overflow-unhandled-microsoft-net-4-5-asp-net-mvc-3-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:24:09","modified_gmt":"2022-08-30T15:24:09","slug":"iis-crash-on-stack-overflow-unhandled-microsoft-net-4-5-asp-net-mvc-3-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/iis-crash-on-stack-overflow-unhandled-microsoft-net-4-5-asp-net-mvc-3-collection-of-common-programming-errors\/","title":{"rendered":"IIS Crash on stack overflow (unhandled) &#8211; Microsoft .NET 4.5 ASP.NET MVC 3-Collection of common programming errors"},"content":{"rendered":"<p>I have wrong behavior of ASP.NET MVC 3 application on IIS 7. We had stack overflow condition in code and it caused general application pool crash <strong>without correct System.StackOveflowException throwing<\/strong>. So, after starting of executing problematic function <strong>w3wp.exe goes down with native code exception<\/strong>.<\/p>\n<p>Here is the code of HtmlHelper extension(now &#8211; fixed):<\/p>\n<pre><code>public static string Avatar( this UrlHelper helper, string fileName)\n    {\n        return helper.UserAvatar(fileName);\n    }\n\npublic static string UserAvatar( this UrlHelper helper, string fileName)\n    {\n        if (string.IsNullOrEmpty(fileName))\n            return EmptyPhotoImage(helper);\n\n        var photoPath = System.Web.Hosting.HostingEnvironment.MapPath(string.Format(\"~\/Content\/avatars\/{0}\", fileName));\n        if (!File.Exists(photoPath))\n            return EmptyPhotoImage(helper);\n\n        return Avatar(helper, fileName);\n\n    }\n<\/code><\/pre>\n<p>Here is the event log record:<\/p>\n<pre><code>Faulting application name: w3wp.exe, version: 7.5.7601.17514, time stamp: 0x4ce7afa2\nFaulting module name: ntdll.dll, version: 6.1.7601.17725, time stamp: 0x4ec4aa8e\nException code: 0xc00000fd\nFault offset: 0x0000000000055d7f\nFaulting process id: 0x1a6c\nFaulting application start time: 0x01ce6c67c7179807\nFaulting application path: c:\\windows\\system32\\inetsrv\\w3wp.exe\nFaulting module path: C:\\Windows\\SYSTEM32\\ntdll.dll\nReport Id: 0dd50093-d85b-11e2-9ee7-50e549e13906\n<\/code><\/pre>\n<p>Other one:<\/p>\n<pre><code>Fault bucket , type 0\nEvent Name: APPCRASH\nResponse: Not available\nCab Id: 0\n\nProblem signature:\nP1: w3wp.exe\nP2: 7.5.7601.17514\nP3: 4ce7afa2\nP4: ntdll.dll\nP5: 6.1.7601.17725\nP6: 4ec4aa8e\nP7: c00000fd\nP8: 0000000000055d7f\nP9: \nP10: \n<\/code><\/pre>\n<p>My question: Why it causes pool crash without StackOverflowException?<\/p>\n<ol>\n<li>\n<p>Because you cause a recursive infinite invokation.<\/p>\n<p>Avatar invokes UserAvatar which invokes Avatar if a certain condition is met, e.g when you have no file on disk.<\/p>\n<p>Hence the StackOverflowException, which makes it impossible for the application to keep on running. Thats why you get a native exception (since it&#8217;s the CLR that is crasching. Event 0xc00000fd is a StacokOverflowException)<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2014-01-05 22:04:07. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I have wrong behavior of ASP.NET MVC 3 application on IIS 7. We had stack overflow condition in code and it caused general application pool crash without correct System.StackOveflowException throwing. So, after starting of executing problematic function w3wp.exe goes down with native code exception. Here is the code of HtmlHelper extension(now &#8211; fixed): public static [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2352","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2352","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2352"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2352\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2352"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2352"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2352"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}