Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.
Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.
Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.
Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.
Using aggressive method inlining in some case optimizes the method out of existence. I do not know if this issue manifests itself only in this particular case or there are other circumstances in which the same behavior can be observed, but here is the specific use case from the Akka.NET project: [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Tcp.SocketCompleted ResolveMessage(SocketAsyncEventArgs e) { switch (e.LastOperation) { case SocketAsyncOperation.Receive: case SocketAsyncOperation.ReceiveFrom: case SocketAsyncOperation.ReceiveMessageFrom: return Tcp.SocketReceived.Instance; case SocketAsyncOperation.Send: case SocketAsyncOperation.SendTo: case SocketAsyncOperation.SendPackets: return Tcp.SocketSent.Instance; case SocketAsyncOperation.Accept: return Tcp.SocketAccepted.Instance; case SocketAsyncOperation.Connect: return Tcp.SocketConnected.Instance; default: throw new NotSupportedException($"Socket operation {e.LastOperation} is not supported"); } } Attribute [MethodImpl(MethodImplOptions.AggressiveInlining)] causes this method to ALWAYS return NULL under at least Mono 5.2.0.215. I have encountered the problem on Ubuntu 17.04, but others seem to be having the same issue on Windows too. Akka.NET bug report is here: https://github.com/akkadotnet/akka.net/issues/3092#issuecomment-328576938 Removing the attribute or disabling inline optimization (mono -O=all,-inline ...) alleviates the problem.
Could you attach a complete testcase ? I couldn't create one from that code fragment.
The original Akka bug report has one: https://github.com/akkadotnet/akka.net/issues/3092#issue-256574196 Would that suffice?
That code doesn't compile either, it has no using directives.
https://github.com/mmoussikhine/Bug59608 Steps to reproduce: "Success" 1. 'Debug' Server 2. 'Run' Client Client will send "Ping" Server will receive "Ping" and respond "Pong" Client will receive "Pong" 3. Stop Server "Failure" 1. 'Run' Server 2. 'Run' Client Client will send "Ping" Server will crash The important part of the exception trace is "Akka.IO.TcpExt.OnComplete". https://github.com/akkadotnet/akka.net/blob/dev/src/core/Akka/IO/Tcp.cs#L1103 Method OnComplete calls ResolveMessage, which in 'Run' mode always returns NULL.
I can reproduce, needed to compile the testcase with csc /optimize. Testcase: <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< using System; using System.Runtime.CompilerServices; using System.Net; using System.Net.Sockets; class Args { public SocketAsyncOperation LastOperation { get; set; } } public class Tests { [MethodImpl(MethodImplOptions.AggressiveInlining)] private static int ResolveMessage(Args e) { switch (e.LastOperation) { case SocketAsyncOperation.Receive: return 0; case SocketAsyncOperation.Send: return 1; case SocketAsyncOperation.Accept: return 2; case SocketAsyncOperation.Connect: return 3; default: throw new NotSupportedException($"Socket operation {e.LastOperation} is not supported"); } } public static void Main () { var e = new Args () { LastOperation = SocketAsyncOperation.Connect }; Console.WriteLine (ResolveMessage(e)); } } >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
https://github.com/mono/mono/pull/5654
Closing the issue has been fixed