{"action":"created","issue":{"url":"https://api.github.com/repos/castleproject/Core/issues/193","repository_url":"https://api.github.com/repos/castleproject/Core","labels_url":"https://api.github.com/repos/castleproject/Core/issues/193/labels{/name}","comments_url":"https://api.github.com/repos/castleproject/Core/issues/193/comments","events_url":"https://api.github.com/repos/castleproject/Core/issues/193/events","html_url":"https://github.com/castleproject/Core/issues/193","id":164036149,"node_id":"MDU6SXNzdWUxNjQwMzYxNDk=","number":193,"title":"TypeLoadException or BadImageFormatException under heavy multi-threaded proxy generation","user":{"login":"bluerobotch","id":3074874,"node_id":"MDQ6VXNlcjMwNzQ4NzQ=","avatar_url":"https://avatars2.githubusercontent.com/u/3074874?v=4","gravatar_id":"","url":"https://api.github.com/users/bluerobotch","html_url":"https://github.com/bluerobotch","followers_url":"https://api.github.com/users/bluerobotch/followers","following_url":"https://api.github.com/users/bluerobotch/following{/other_user}","gists_url":"https://api.github.com/users/bluerobotch/gists{/gist_id}","starred_url":"https://api.github.com/users/bluerobotch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bluerobotch/subscriptions","organizations_url":"https://api.github.com/users/bluerobotch/orgs","repos_url":"https://api.github.com/users/bluerobotch/repos","events_url":"https://api.github.com/users/bluerobotch/events{/privacy}","received_events_url":"https://api.github.com/users/bluerobotch/received_events","type":"User","site_admin":false},"labels":[{"id":332238400,"node_id":"MDU6TGFiZWwzMzIyMzg0MDA=","url":"https://api.github.com/repos/castleproject/Core/labels/bug","name":"bug","color":"e11d21","default":true},{"id":84189335,"node_id":"MDU6TGFiZWw4NDE4OTMzNQ==","url":"https://api.github.com/repos/castleproject/Core/labels/up-for-grabs","name":"up-for-grabs","color":"0e8a16","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":113,"created_at":"2016-07-06T09:35:56Z","updated_at":"2018-06-25T05:52:24Z","closed_at":null,"author_association":"NONE","body":"We use Moq 4.5.10 with Castle.Core 3.3.3 and xUnit 2.1.0 for our unit tests. For xUnit we have the option activated to only have one app domain for all tests. We also enabled parallelization of test execution in xUnit.\n\nSporadically we get TypeLoadExceptions like the following example:\n`System.TypeLoadException : Could not load type 'Castle.Proxies.Invocations.IExecutorAccessor_Prepare' from assembly 'DynamicProxyGenAssembly2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=a621a9e7e5c32e69'.\nat Castle.Proxies.IExecutorAccessorProxy.Prepare[TExecutionUnit](TExecutionUnit executionUnit)\n....\n`\n\nWe reviewed the source code of Moq to ensure there is no threading issue with the ProxyGenerator caching. But Moq looks fine.\n\nWhen disabling xUnit test parallelization we don't get TypeLoadExceptions anymore. For this reason we think it is a race condition in Castle.Core or even in the .Net Framework.\n\nAs far as we see, the missing type is the type that is created for the invocation by InterfaceProxyWithoutTargetContributor.GetInvocationType. The TypeLoadException seems to be raised in the code that is emitted for the invocation in MethodWithInvocationGenerator.BuildProxiedMethodBody. The invocation type is built before it is used in the emitted code. Therefore we do not see a reason why the type cannot be loaded.\n"},"comment":{"url":"https://api.github.com/repos/castleproject/Core/issues/comments/399839323","html_url":"https://github.com/castleproject/Core/issues/193#issuecomment-399839323","issue_url":"https://api.github.com/repos/castleproject/Core/issues/193","id":399839323,"node_id":"MDEyOklzc3VlQ29tbWVudDM5OTgzOTMyMw==","user":{"login":"BrunoJuchli","id":2090172,"node_id":"MDQ6VXNlcjIwOTAxNzI=","avatar_url":"https://avatars1.githubusercontent.com/u/2090172?v=4","gravatar_id":"","url":"https://api.github.com/users/BrunoJuchli","html_url":"https://github.com/BrunoJuchli","followers_url":"https://api.github.com/users/BrunoJuchli/followers","following_url":"https://api.github.com/users/BrunoJuchli/following{/other_user}","gists_url":"https://api.github.com/users/BrunoJuchli/gists{/gist_id}","starred_url":"https://api.github.com/users/BrunoJuchli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BrunoJuchli/subscriptions","organizations_url":"https://api.github.com/users/BrunoJuchli/orgs","repos_url":"https://api.github.com/users/BrunoJuchli/repos","events_url":"https://api.github.com/users/BrunoJuchli/events{/privacy}","received_events_url":"https://api.github.com/users/BrunoJuchli/received_events","type":"User","site_admin":false},"created_at":"2018-06-25T05:52:24Z","updated_at":"2018-06-25T05:52:24Z","author_association":"CONTRIBUTOR","body":"In just under 65hours 1 out of 33 processes of https://github.com/BrunoJuchli/Core/tree/GlobalLock failed with a `BadImageFormatException` \r\n>The signature is incorrect\r\nat Castle.Proxies.IClass693Proxy.DoSomething()\r\nat NetCoreRepro.ToDuplicate.Test693.DoSomething()\r\n\r\nI guess, then, that we should now concentrate on bringing this down to a minmal repro for Microsoft, right?\r\n\r\nWe should give consideration to the observed effect of putting a lock (sequentializing) around it did not prevent the issue from occurring, but did massively decrease the likelihood.\r\nI suggest we first try to reproduce the issue with minimal code & fine locking.\r\nWe can then still add coarser locking, if deemed sensible."}}
{"actor":{"display_login":"BrunoJuchli"}}