{"action":"created","issue":{"url":"https://api.github.com/repos/mono/mono/issues/7596","repository_url":"https://api.github.com/repos/mono/mono","labels_url":"https://api.github.com/repos/mono/mono/issues/7596/labels{/name}","comments_url":"https://api.github.com/repos/mono/mono/issues/7596/comments","events_url":"https://api.github.com/repos/mono/mono/issues/7596/events","html_url":"https://github.com/mono/mono/issues/7596","id":304880960,"number":7596,"title":"Crash (NullReferenceException) in managed-to-native wrapper on Win64","user":{"login":"joncham","id":260892,"avatar_url":"https://avatars3.githubusercontent.com/u/260892?v=4","gravatar_id":"","url":"https://api.github.com/users/joncham","html_url":"https://github.com/joncham","followers_url":"https://api.github.com/users/joncham/followers","following_url":"https://api.github.com/users/joncham/following{/other_user}","gists_url":"https://api.github.com/users/joncham/gists{/gist_id}","starred_url":"https://api.github.com/users/joncham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joncham/subscriptions","organizations_url":"https://api.github.com/users/joncham/orgs","repos_url":"https://api.github.com/users/joncham/repos","events_url":"https://api.github.com/users/joncham/events{/privacy}","received_events_url":"https://api.github.com/users/joncham/received_events","type":"User","site_admin":false},"labels":[{"id":844253802,"url":"https://api.github.com/repos/mono/mono/labels/area-Runtime:%20Interop","name":"area-Runtime: Interop","color":"d4c5f9","default":false},{"id":776600565,"url":"https://api.github.com/repos/mono/mono/labels/os-windows","name":"os-windows","color":"fef2c0","default":false}],"state":"open","locked":false,"assignee":{"login":"lateralusX","id":11529140,"avatar_url":"https://avatars0.githubusercontent.com/u/11529140?v=4","gravatar_id":"","url":"https://api.github.com/users/lateralusX","html_url":"https://github.com/lateralusX","followers_url":"https://api.github.com/users/lateralusX/followers","following_url":"https://api.github.com/users/lateralusX/following{/other_user}","gists_url":"https://api.github.com/users/lateralusX/gists{/gist_id}","starred_url":"https://api.github.com/users/lateralusX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lateralusX/subscriptions","organizations_url":"https://api.github.com/users/lateralusX/orgs","repos_url":"https://api.github.com/users/lateralusX/repos","events_url":"https://api.github.com/users/lateralusX/events{/privacy}","received_events_url":"https://api.github.com/users/lateralusX/received_events","type":"User","site_admin":false},"assignees":[{"login":"lateralusX","id":11529140,"avatar_url":"https://avatars0.githubusercontent.com/u/11529140?v=4","gravatar_id":"","url":"https://api.github.com/users/lateralusX","html_url":"https://github.com/lateralusX","followers_url":"https://api.github.com/users/lateralusX/followers","following_url":"https://api.github.com/users/lateralusX/following{/other_user}","gists_url":"https://api.github.com/users/lateralusX/gists{/gist_id}","starred_url":"https://api.github.com/users/lateralusX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lateralusX/subscriptions","organizations_url":"https://api.github.com/users/lateralusX/orgs","repos_url":"https://api.github.com/users/lateralusX/repos","events_url":"https://api.github.com/users/lateralusX/events{/privacy}","received_events_url":"https://api.github.com/users/lateralusX/received_events","type":"User","site_admin":false}],"milestone":null,"comments":2,"created_at":"2018-03-13T18:19:26Z","updated_at":"2018-03-14T16:03:54Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"## Steps to Reproduce\r\n\r\n1. Build the following C++ into a dynamic library\r\n2. Build the sample C# code\r\n3. Run with Mono on Windows 64-bit with debugger sequence points enabled (I'm setting `MONO_DEBUG=gen-seq-points`)\r\n\r\n```\r\n// C++\r\ntypedef struct\r\n{\r\n\tuint16_t a;\r\n\tint32_t b; // Boolean comes in as int32_t\r\n\tint32_t c; // Boolean comes in as int32_t\r\n\r\n} StructToMarshal;\r\n\r\nstatic StructToMarshal local;\r\n\r\nextern \"C\" __declspec(dllexport) void NativeMethod (StructToMarshal options)\r\n{\r\n\tlocal = options;\r\n}\r\n```\r\n\r\n```\r\n// C#\r\nusing System.Runtime.InteropServices;\r\n\r\nclass Program\r\n{\r\n    static void Main()\r\n    {\r\n        var o = new StructToMarshal();\r\n        NativeMethod(o);\r\n    }\r\n\r\n    [DllImport(\"DynamicLibrary.dll\")]\r\n    static extern void NativeMethod(StructToMarshal options);\r\n    public struct StructToMarshal\r\n    {\r\n        public ushort a;\r\n        public bool b;\r\n        public bool c;\r\n    }\r\n}\r\n```\r\n## Current Behavior\r\n\r\n```\r\nUnhandled Exception:\r\nSystem.NullReferenceException: Object reference not set to an instance of an object\r\n  at (wrapper managed-to-native) Program.NativeMethod(Program/StructToMarshal)\r\n  at Program.Main () [0x00009] in <d6a5c184bbdb418bb6ee378ea93cbefb>:0\r\n[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object\r\n  at (wrapper managed-to-native) Program.NativeMethod(Program/StructToMarshal)\r\n  at Program.Main () [0x00009] in <d6a5c184bbdb418bb6ee378ea93cbefb>:0\r\n```\r\n\r\n## Expected Behavior\r\n\r\nNo crash\r\n\r\n### On which platforms did you notice this\r\n\r\n[ ] macOS\r\n[ ] Linux\r\n[ X] Windows\r\n\r\n**Version Used**:\r\n```\r\nMono JIT compiler version 5.11.0 (Visual Studio built mono)\r\nCopyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com\r\n        TLS:           normal\r\n        SIGSEGV:       normal\r\n        Notification:  Thread + polling\r\n        Architecture:  amd64\r\n        Disabled:      none\r\n        Misc:          softdebug\r\n        Interpreter:   yes\r\n        LLVM:          supported, not enabled.\r\n        GC:            sgen (concurrent by default)\r\n```"},"comment":{"url":"https://api.github.com/repos/mono/mono/issues/comments/373076548","html_url":"https://github.com/mono/mono/issues/7596#issuecomment-373076548","issue_url":"https://api.github.com/repos/mono/mono/issues/7596","id":373076548,"user":{"login":"lateralusX","id":11529140,"avatar_url":"https://avatars0.githubusercontent.com/u/11529140?v=4","gravatar_id":"","url":"https://api.github.com/users/lateralusX","html_url":"https://github.com/lateralusX","followers_url":"https://api.github.com/users/lateralusX/followers","following_url":"https://api.github.com/users/lateralusX/following{/other_user}","gists_url":"https://api.github.com/users/lateralusX/gists{/gist_id}","starred_url":"https://api.github.com/users/lateralusX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lateralusX/subscriptions","organizations_url":"https://api.github.com/users/lateralusX/orgs","repos_url":"https://api.github.com/users/lateralusX/repos","events_url":"https://api.github.com/users/lateralusX/events{/privacy}","received_events_url":"https://api.github.com/users/lateralusX/received_events","type":"User","site_admin":false},"created_at":"2018-03-14T16:03:54Z","updated_at":"2018-03-14T16:03:54Z","author_association":"MEMBER","body":"Found a similar issue with empty struct returns from pinvoke (0 managed size) when running pinvoke unit tests with sequence points enabled. Will include fix for this in same PR."}}
{"actor":{"display_login":"lateralusX"}}