Bug 58261 - TcpBinaryFrameManager.MyBinaryWriter::GetSizeOfLength - Wrongly returns size of 7BitEncoder Int.
Summary: TcpBinaryFrameManager.MyBinaryWriter::GetSizeOfLength - Wrongly returns size ...
Alias: None
Product: Class Libraries
Classification: Mono
Component: WCF assemblies ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2017-07-19 22:36 UTC by Tom Hindle
Modified: 2017-10-23 22:48 UTC (History)
2 users (show)

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

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.

Related Links:

Description Tom Hindle 2017-07-19 22:36:55 UTC
TcpBinaryFrameManager.MyBinaryWriter::GetSizeOfLength - Wrong reads size of 7BitEncoder Init.

For Example:


Actual Output: 1
Expected Output: 2

This bug breaks, at the very least, WCF with NetBindingTcp, using DataContractSerializer (not XmlSerializer)

Leads to error messages like (on .net clients):

System.ServiceModel.CommunicationException: Error in deserializing body of reply message for operation 'Sync'. Unexpected end of file. Following elements are not closed: Envelope. ---> System.Xml.XmlException: Unexpected end of file. Following elements are not closed: Envelope.

Suggested Patch:

diff -r 57e47df5b9f6 -r f373d5a934c0 System.ServiceModel/System.ServiceModel.Channels.NetTcp/TcpBinaryFrameManager.cs
--- a/System.ServiceModel/System.ServiceModel.Channels.NetTcp/TcpBinaryFrameManager.cs	Tue Jul 18 13:13:46 2017 -0600
+++ b/System.ServiceModel/System.ServiceModel.Channels.NetTcp/TcpBinaryFrameManager.cs	Wed Jul 19 16:29:21 2017 -0600
@@ -68,17 +68,17 @@ namespace System.ServiceModel.Channels.N
 				Write7BitEncodedInt (value);
 			public int GetSizeOfLength (int value)
 				int x = 0;
 				do {
-					value /= 0x100;
+					value /= 0x7f;
 				} while (value != 0);
 				return x;
 		class MyXmlBinaryWriterSession : XmlBinaryWriterSession
Comment 1 Tom Hindle 2017-07-19 22:44:23 UTC
Actually thinking about it:

prolly should be:

-					value /= 0x100;
+					value /= 0x80;

As MyBinaryWritter::GetSizeOfLength(127);

Should return 1

And As MyBinaryWritter::GetSizeOfLength(128);

Should return 2.
Comment 3 Alexander Köplinger [MSFT] 2017-10-23 22:48:13 UTC
This was fixed with https://github.com/mono/mono/pull/5842, thank you!