Bug 23798 - Xamarin Bug in BinaryReader + DeflateStream interaction?
Summary: Xamarin Bug in BinaryReader + DeflateStream interaction?
Status: VERIFIED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: XI 8.2.0
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: Untriaged
Assignee: Rolf Bjarne Kvinge [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2014-10-13 18:46 UTC by Jon Goldberger [MSFT]
Modified: 2014-11-26 12:58 UTC (History)
4 users (show)

Tags:
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 Developer Community or GitHub 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:
Status:
VERIFIED FIXED

Description Jon Goldberger [MSFT] 2014-10-13 18:46:13 UTC
## Customer's Description

I just recognized a strange bug when I tried to de-serialize (using my own lightweight deserialization process) a compressed data packet I serialized on a Windows machine before.

Please note that de-serializing other packets, serialized with exactly the same serializer code, is working fine. It looks like an edge-case in the DeflateStream + BinaryReader collaboration. The code I attached is working fine on Windows but crashing in Xamarin iOS (on a real device and in the simulator), no matter if iOS 7.1 or iOS 8. I am using the Xamarin beta channel and the VisualStudio plugin.

I left the serialization code in the code example for clarity (and allow you some experiments), even when the example is not using it.

## Steps to reproduce

1. Open attached solution and set the iOS project as the startup project.
2. Run the app to a simulator or device.

## Expected result

App does not throw exception

## Actual result

App throws following exception:

>System.IO.EndOfStreamException: Failed to read past end of stream.
>  at System.IO.BinaryReader.ReadByte () [0x00047] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.IO/BinaryReader.cs:318
>  at TestCustSerDeset.iOS.Recipe.DeSerialize (System.IO.BinaryReader stream) [0x0005e] in /Users/apple/Documents/Xamarin/XamSupport/TestCustSerDeser/TestCustSerDeset.iOS/TestCustSerDeset.iOSViewController.cs:91
>  at TestCustSerDeset.iOS.TestCustSerDeset_iOSViewController.ViewDidLoad () [0x00087] in /Users/apple/Documents/Xamarin/XamSupport/TestCustSerDeser/TestCustSerDeset.iOS/TestCustSerDeset.iOSViewController.cs:132
>  at at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
>  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) [0x00005] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:62
>  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:46
>  at TestCustSerDeset.iOS.Application.Main (System.String[] args) [0x00008] in /Users/apple/Documents/Xamarin/XamSupport/TestCustSerDeser/TestCustSerDeset.iOS/Main.cs:17


## Notes

There is also a console project in the solution with the same code that does not throw the above exception. 


## My version info:

=== Xamarin Studio ===

Version 5.5 (build 227)
Installation UUID: 2dc9022f-f9a8-424f-8284-bf224cbbfde0
Runtime:
	Mono 3.10.0 ((detached/47db868)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 310000019

=== Apple Developer Tools ===

Xcode 6.0.1 (6528)
Build 6A317

=== Xamarin.iOS ===

Version: 8.2.0.193 (Business Edition)
Hash: 959c1e4
Branch: 
Build date: 2014-10-03 00:25:37-0400

=== Xamarin.Android ===

Version: 4.18.0 (Business Edition)
Android SDK: /Users/apple/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		2.2   (API level 8)
		2.3   (API level 10)
		3.0   (API level 11)
		3.1   (API level 12)
		3.2   (API level 13)
		4.0   (API level 14)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.2   (API level 17)
		4.3   (API level 18)
		4.4   (API level 19)
Java SDK: /usr
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

=== Xamarin.Mac ===

Version: 1.10.0.13 (Business Edition)

=== Build Information ===

Release ID: 505000227
Git revision: 7b721eeec7a2fa4c4f4de0ecd2aed4dc25edac95
Build date: 2014-10-02 15:53:38-04
Xamarin addins: 99ed56b428b31eba1efaace4d82188d6f334e6ca

=== Operating System ===

Mac OS X 10.9.5
Darwin Jonathans-MacBook-Pro.local 13.4.0 Darwin Kernel Version 13.4.0
    Sun Aug 17 19:50:11 PDT 2014
    root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64
Comment 2 Sadik Ali 2014-10-14 04:01:38 UTC
I have checked this issue and able to reproduce this. To reproduce this issue I have followed the steps provided in bug description.

Steps I have followed:

1. Open attached solution provided in bug description
2. Set the iOS project as the startup project.
3. Run the app to a simulator or device.
4. Observe that you will get: System.IO.EndOfStreamException

Additional Information: I also run the console project in the solution with the same code that does
not throws any exception. 

Exception: https://gist.github.com/Rajneesh360Logica/e638dada69d4dae9cfe9

Screencast: http://www.screencast.com/t/trjblvuCxXt

Environment Info:

=== Xamarin Studio ===

Version 5.5 (build 227)
Installation UUID: 011d70a5-dede-428b-ab04-ef451c2e539d
Runtime:
	Mono 3.10.0 ((detached/47db868)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 310000019

=== Apple Developer Tools ===

Xcode 5.1 (5084)
Build 5B130a

=== Xamarin.Mac ===

Version: 1.10.0.13 (Business Edition)

=== Xamarin.Android ===

Version: 4.18.0 (Business Edition)
Android SDK: /Users/MM/Desktop/android-sdk-macosx
	Supported Android versions:
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		3.2    (API level 13)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		4.5    (API level 21)
Java SDK: /usr
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

=== Xamarin.iOS ===

Version: 8.2.0.193 (Business Edition)
Hash: 959c1e4
Branch: 
Build date: 2014-10-03 00:25:37-0400

=== Build Information ===

Release ID: 505000227
Git revision: 7b721eeec7a2fa4c4f4de0ecd2aed4dc25edac95
Build date: 2014-10-02 15:53:38-04
Xamarin addins: 99ed56b428b31eba1efaace4d82188d6f334e6ca

=== Operating System ===

Mac OS X 10.9.5
Darwin MacMini.local 13.4.0 Darwin Kernel Version 13.4.0
    Sun Aug 17 19:50:11 PDT 2014
    root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64
Comment 3 Rolf Bjarne Kvinge [MSFT] 2014-10-14 07:05:14 UTC
Fixed.

monotouch/master: 1672128bc38e573d77b4e72cb21a9d99d0f84f8e
Comment 4 narayanp 2014-11-26 12:58:57 UTC
I have checked this issue and now this issue works fine.

I downloaded attached sample application and run iOS project in this solution on Simulator and device then It runs successfully on both Simulator and device without throw any exception.

I also run the console project in this solution and it also runs successfully without throw any exception. 

Screencast: http://www.screencast.com/t/AXsE9QAk1

Environment info:
=== Xamarin Studio ===

Version 5.7 (build 596)
Installation UUID: 011d70a5-dede-428b-ab04-ef451c2e539d
Runtime:
	Mono 3.12.0 ((detached/b75fa2b)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312000046

=== Apple Developer Tools ===

Xcode 6.1 (6604)
Build 6A1052d

=== Xamarin.iOS ===

Version: 8.6.0.5 (Business Edition)
Hash: 880cc21
Branch: 
Build date: 2014-11-25 12:12:17-0500

=== Xamarin.Android ===

Version: 5.0.0.0 (Business Edition)
Android SDK: /Users/MM/Desktop/android-sdk-macosx
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

=== Xamarin.Mac ===

Version: 1.11.1.201 (Business Edition)

=== Build Information ===

Release ID: 507000596
Git revision: d996e9ba6874a0d64241e43e5e6b06322ce29c84
Build date: 2014-11-25 17:17:54-05
Xamarin addins: 8ca19707b41536a391f53364ee4ff9272711feb0

=== Operating System ===

Mac OS X 10.9.5
Darwin MacMini.local 13.4.0 Darwin Kernel Version 13.4.0
    Sun Aug 17 19:50:11 PDT 2014
    root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64