Bug 51658 - BeginInvoke over RealProxy fails if function has no out or ref parameters
Summary: BeginInvoke over RealProxy fails if function has no out or ref parameters
Status: NEW
Alias: None
Product: Runtime
Classification: Mono
Component: Remoting ()
Version: 4.6.0 (C8)
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2017-01-20 10:50 UTC by Sam Hocevar
Modified: 2017-01-20 11:00 UTC (History)
3 users (show)

Is this bug a regression?: ---
Last known good build:

Test case to reproduce issue (1.15 KB, application/gzip)
2017-01-20 10:50 UTC, Sam Hocevar

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 for Bug 51658 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Sam Hocevar 2017-01-20 10:50:47 UTC
Created attachment 19413 [details]
Test case to reproduce issue

BeginInvoke does not work over RealProxy if the following conditions are met:

  - the server runs under Mono
  - the client runs under the .NET runtime
  - the function being called has no out or ref parameters

All other combinations of Mono/.NET for the client and the server appear to work properly. Likewise, if at least one parameter of the function has an out or ref attribute, everything works as expected.

Attached is a test case (based on the Microsoft sample found at https://msdn.microsoft.com/en-us/library/ms973857.aspx). In order to test it, run server.exe without arguments, then run client.exe with the server’s IP address as its argument.

Expected output:

Hello #1
Hello #2
Hello #3
Hello #4
Hello #5

Actual output (when the client runs on Windows):

Hello #1
Hello #2
Hello #3
Hello #4

Unhandled Exception: System.OverflowException: Arithmetic operation resulted in an overflow.
   at System.Runtime.Remoting.Messaging.Message.InternalGetArgs()
   at System.Runtime.Remoting.Proxies.RealProxy.PropagateOutParameters(IMessage msg, Object[] outArgs, Object returnValue)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at RemotingBug.Client.HelloMethodDelegate.EndInvoke(IAsyncResult result)
   at RemotingBug.Client.Main(String[] args)

When investigating this issue I found an obvious bug in mcs/class/System.ServiceModel/System.ServiceModel/ClientRealProxy.cs where the variable outArgs is never actually constructed, but is used to build a return value. I also found about this bug and associated patch: https://bugzilla.xamarin.com/show_bug.cgi?id=11414 which might be related.