{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/5599","labels_url":"https://api.github.com/repos/dotnet/roslyn/issues/5599/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/5599/comments","events_url":"https://api.github.com/repos/dotnet/roslyn/issues/5599/events","html_url":"https://github.com/dotnet/roslyn/issues/5599","id":109202973,"number":5599,"title":"Bad codegen (causing runtime crash)","user":{"login":"pharring","id":9952654,"avatar_url":"https://avatars.githubusercontent.com/u/9952654?v=3","gravatar_id":"","url":"https://api.github.com/users/pharring","html_url":"https://github.com/pharring","followers_url":"https://api.github.com/users/pharring/followers","following_url":"https://api.github.com/users/pharring/following{/other_user}","gists_url":"https://api.github.com/users/pharring/gists{/gist_id}","starred_url":"https://api.github.com/users/pharring/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pharring/subscriptions","organizations_url":"https://api.github.com/users/pharring/orgs","repos_url":"https://api.github.com/users/pharring/repos","events_url":"https://api.github.com/users/pharring/events{/privacy}","received_events_url":"https://api.github.com/users/pharring/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dotnet/roslyn/labels/Area-Compilers","name":"Area-Compilers","color":"5319e7"},{"url":"https://api.github.com/repos/dotnet/roslyn/labels/Bug","name":"Bug","color":"fc2929"}],"state":"open","locked":false,"assignee":{"login":"VSadov","id":8218165,"avatar_url":"https://avatars.githubusercontent.com/u/8218165?v=3","gravatar_id":"","url":"https://api.github.com/users/VSadov","html_url":"https://github.com/VSadov","followers_url":"https://api.github.com/users/VSadov/followers","following_url":"https://api.github.com/users/VSadov/following{/other_user}","gists_url":"https://api.github.com/users/VSadov/gists{/gist_id}","starred_url":"https://api.github.com/users/VSadov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VSadov/subscriptions","organizations_url":"https://api.github.com/users/VSadov/orgs","repos_url":"https://api.github.com/users/VSadov/repos","events_url":"https://api.github.com/users/VSadov/events{/privacy}","received_events_url":"https://api.github.com/users/VSadov/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/dotnet/roslyn/milestones/3","html_url":"https://github.com/dotnet/roslyn/milestones/1.1","labels_url":"https://api.github.com/repos/dotnet/roslyn/milestones/3/labels","id":937401,"number":3,"title":"1.1","description":"This is our 1.1 Milestone.\r\n\r\n<!---\r\n@huboard:{\"order\":1.5}\r\n-->\r\n","creator":{"login":"jaredpar","id":146967,"avatar_url":"https://avatars.githubusercontent.com/u/146967?v=3","gravatar_id":"","url":"https://api.github.com/users/jaredpar","html_url":"https://github.com/jaredpar","followers_url":"https://api.github.com/users/jaredpar/followers","following_url":"https://api.github.com/users/jaredpar/following{/other_user}","gists_url":"https://api.github.com/users/jaredpar/gists{/gist_id}","starred_url":"https://api.github.com/users/jaredpar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaredpar/subscriptions","organizations_url":"https://api.github.com/users/jaredpar/orgs","repos_url":"https://api.github.com/users/jaredpar/repos","events_url":"https://api.github.com/users/jaredpar/events{/privacy}","received_events_url":"https://api.github.com/users/jaredpar/received_events","type":"User","site_admin":false},"open_issues":280,"closed_issues":462,"state":"open","created_at":"2015-01-15T20:48:41Z","updated_at":"2015-10-01T00:13:40Z","due_on":null,"closed_at":null},"comments":3,"created_at":"2015-09-30T23:51:46Z","updated_at":"2015-10-01T03:30:04Z","closed_at":null,"body":"Compile the following with /optimize+ /t:exe\r\n\r\n```C#\r\nusing System;\r\nusing System.Runtime.CompilerServices;\r\n\r\nnamespace CSharpeApp\r\n{\r\n    class Program\r\n    {\r\n        public class Engine\r\n        {\r\n            // un-comment to fix the issue in Visual Studio 2015\r\n            //[MethodImpl(MethodImplOptions.AggressiveInlining)]\r\n            public string GetResourceString(string category, string symbol, string defaultSymbol, out Object foundObj)\r\n            {\r\n                foundObj = new Boolean();\r\n\r\n                return \"Hello world\" + category + symbol;\r\n            }\r\n        }\r\n\r\n        static public string RString(Engine tsEngine, string category, string symbol, out bool found)\r\n        {\r\n            string retval = \"\";\r\n            object foundObj;\r\n\r\n            found = false;\r\n            retval = tsEngine.GetResourceString(category, symbol, symbol, out foundObj);\r\n            found = (bool)foundObj;\r\n\r\n            return retval;\r\n        }\r\n\r\n        static void Main(string[] args)\r\n        {\r\n            Engine tsEngine = new Engine();\r\n            bool found;\r\n\r\n            string result = RString(tsEngine, \"FOO\", \"BAR\", out found);\r\n\r\n            if (!found)\r\n            {\r\n                System.Console.WriteLine(result);\r\n            }\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nRun the resulting program.\r\nResult: NRE\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/comments/144608966","html_url":"https://github.com/dotnet/roslyn/issues/5599#issuecomment-144608966","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/5599","id":144608966,"user":{"login":"pharring","id":9952654,"avatar_url":"https://avatars.githubusercontent.com/u/9952654?v=3","gravatar_id":"","url":"https://api.github.com/users/pharring","html_url":"https://github.com/pharring","followers_url":"https://api.github.com/users/pharring/followers","following_url":"https://api.github.com/users/pharring/following{/other_user}","gists_url":"https://api.github.com/users/pharring/gists{/gist_id}","starred_url":"https://api.github.com/users/pharring/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pharring/subscriptions","organizations_url":"https://api.github.com/users/pharring/orgs","repos_url":"https://api.github.com/users/pharring/repos","events_url":"https://api.github.com/users/pharring/events{/privacy}","received_events_url":"https://api.github.com/users/pharring/received_events","type":"User","site_admin":false},"created_at":"2015-10-01T03:30:04Z","updated_at":"2015-10-01T03:30:04Z","body":"Here's the x86 code with JIT32\r\n\r\n```\r\n00FE2DD0  push        ebp  \r\n00FE2DD1  mov         ebp,esp  \r\n00FE2DD3  sub         esp,0Ch  \r\n00FE2DD6  xor         eax,eax  \r\n00FE2DD8  mov         dword ptr [ebp-4],eax  \r\n00FE2DDB  mov         dword ptr [ebp-0Ch],eax  \r\n00FE2DDE  mov         dword ptr [ebp-8],ecx  \r\n00FE2DE1  mov         eax,dword ptr [ebp-4]  \r\n00FE2DE4  cmp         dword ptr [eax],7279F3D8h  \r\n00FE2DEA  je          00FE2DF9  \r\n00FE2DEC  mov         edx,dword ptr [ebp-4]  \r\n00FE2DEF  mov         ecx,7279F3D8h  \r\n00FE2DF4  call        73794A95  \r\n00FE2DF9  mov         ecx,dword ptr ds:[37822A0h]  \r\n00FE2DFF  lea         edx,[ebp-4]  \r\n00FE2E02  call        dword ptr ds:[53B0860h]  \r\n00FE2E08  mov         dword ptr [ebp-0Ch],eax  \r\n00FE2E0B  mov         eax,dword ptr [ebp-4]  \r\n00FE2E0E  movzx       eax,byte ptr [eax+4]  \r\n00FE2E12  mov         edx,dword ptr [ebp-8]  \r\n00FE2E15  mov         byte ptr [edx],al  \r\n00FE2E17  mov         eax,dword ptr [ebp-0Ch]  \r\n00FE2E1A  mov         esp,ebp  \r\n00FE2E1C  pop         ebp  \r\n00FE2E1D  ret  \r\n```\r\n\r\nThe Null Reference happens at 00FE2DE4. It looks like this is a type check for unboxing the Boolean. However that check has been moved ahead of the call to 'GetResourceString' (at 00FE2E02). We need a JIT expert on this. @mmitche, @CarolEidt can one of you take a look?\r\n"}}