Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Starting in Mono 6.0 (2019-02), NotImplementedException prevents using StreamWriter with GZipStream for encodings that use a preamble #16950

Closed
brendanzagaeski opened this issue Sep 19, 2019 · 5 comments · Fixed by #16951

Comments

@brendanzagaeski
Copy link
Contributor

Starting in Mono 6.0 (2019-02), NotImplementedException prevents using StreamWriter with GZipStream for encodings that use a preamble

This is a follow-up to: dotnet/android#3397 (comment) and #16122

Steps to reproduce

Build and run the following program:

using System.IO;
using System.IO.Compression;
using System.Text;


class Program {
	public static void Main (string [] args)
	{
		MemoryStream dest = new MemoryStream ();
		using (GZipStream gzip = new GZipStream (dest, CompressionLevel.Optimal, true))
		using (StreamWriter sw = new StreamWriter (gzip, Encoding.UTF8)) {
			sw.Flush ();
		}
	}
}

Current behavior

With Mono 6.0.0.319 (2019-02/52203786470) and higher, the program aborts due to the following exception:

Unhandled Exception:
System.NotImplementedException: The method or operation is not implemented.
  at System.IO.Compression.DeflateStream.WriteCore (System.ReadOnlySpan`1[T] source) [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-02/external/bockbuild/builds/mono-x64/mcs/class/System/System.IO.Compression/DeflateStream.cs:183 
  at (wrapper remoting-invoke-with-check) System.IO.Compression.DeflateStream.WriteCore(System.ReadOnlySpan`1<byte>)
  at System.IO.Compression.GZipStream.Write (System.ReadOnlySpan`1[T] buffer) [0x00025] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-02/external/bockbuild/builds/mono-x64/external/corefx/src/System.IO.Compression/src/System/IO/Compression/GZipStream.cs:127 
  at System.IO.StreamWriter.Flush (System.Boolean flushStream, System.Boolean flushEncoder) [0x00048] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-02/external/bockbuild/builds/mono-x64/external/corefx/src/Common/src/CoreLib/System/IO/StreamWriter.cs:265 
  at System.IO.StreamWriter.Flush () [0x00006] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-02/external/bockbuild/builds/mono-x64/external/corefx/src/Common/src/CoreLib/System/IO/StreamWriter.cs:239 
  at MainClass.Main (System.String[] args) [0x0001d] in <69e647dabefa4ac185e6a93787396406>:0 

Expected behavior

With Mono 5.18.1.24 (2018-08/082e1a23463), the program completes successfully and exits without error.

(Note that on Mono 6.0 or higher, changing StreamWriter (gzip, Encoding.UTF8) to StreamWriter (gzip) also allows the program to complete successfully because StreamWriter uses new UTF8Encoding (encoderShouldEmitUTF8Identifier: false) by default, and that encoding has a 0-length Preamble.)

On which platforms did you notice this

[x] macOS
[x] Android

@marek-safar
Copy link
Member

@steveisok regression in 6.0

akoeplinger pushed a commit that referenced this issue Sep 20, 2019
No idea why these were left unimplemented (probably were not used at that point).
Fixes #16950
madewokherd pushed a commit to madewokherd/mono that referenced this issue Sep 20, 2019
No idea why these were left unimplemented (probably were not used at that point).
Fixes mono#16950

(cherry picked from commit 3232137)
@ronnyhash
Copy link

When can we expect this in a stable release?

@brendanzagaeski
Copy link
Contributor Author

When can we expect this in a stable release?

If you're wondering about this mostly due to the item https://github.com/Azure/azure-mobile-apps-net-client/issues/514, note that this issue #16950 was also present in Xamarin.Android 9.4.1.1 in Visual Studio 2019 version 16.2 and Visual Studio 2019 for Mac version 8.2, so this issue would not be responsible for the appearance of https://github.com/Azure/azure-mobile-apps-net-client/issues/514 in Xamarin.Android 10.0.0.43 in Visual Studio 2019 version 16.3 and Visual Studio 2019 for Mac version 8.3.

For the question of when the fix for this issue #16950 will be included in a Xamarin.Android release, I don't yet have information to share, but I will keep this issue updated as information becomes available.

@ronnyhash
Copy link

Thank you for giving that explanation! I really appreciate it!

@brendanzagaeski
Copy link
Contributor Author

brendanzagaeski commented Oct 8, 2019

Xamarin release status update

New Release versions of Xamarin.Android, Xamarin.iOS, and Xamarin.Mac have now been published that include the fix for this item.

Fix included in Xamarin.Android 10.0.3.0, Xamarin.iOS 13.2.0.47, and Xamarin.Mac 6.2.0.47

Fix included on Windows in Visual Studio 2019 version 16.3.3. To get the new version that includes the fix, check for the latest updates or install the latest version from https://visualstudio.microsoft.com/downloads/.

Fix included on macOS in Visual Studio 2019 for Mac version 8.3.2. To get the new version that includes the fix, check for the latest updates on the Stable updater channel.


Verification notes: I did a quick local verification for Xamarin.Android 10.0.3.0 to make sure I could still reproduce the original problem before the update and could no longer reproduce the problem after the update.

jonpryor pushed a commit to dotnet/android that referenced this issue Dec 3, 2019
Changes: mono/api-snapshot@fc50bc4...45a61d9

        $ git diff --shortstat fc50bc4f...45a61d93
         22 files changed, 775 insertions(+), 474 deletions(-)

Changes: dotnet/cecil@a6c8f5e...a6a7f5c

        $ git diff --shortstat a6c8f5e1...a6a7f5c0
         55 files changed, 818 insertions(+), 530 deletions(-)

Changes: mono/corefx@1f87de3...49f1c45

        $ git diff --shortstat e4f7102b...49f1c453
         38 files changed, 1171 insertions(+), 419 deletions(-)

Changes: dotnet/linker@ebe2a1f...e8d054b

        $ git diff --shortstat ebe2a1f4...e8d054bf
         137 files changed, 5360 insertions(+), 1781 deletions(-)

Changes: mono/mono@8946e49...18920a8

        $ git diff --shortstat 8946e49a...18920a83
         1811 files changed, 47240 insertions(+), 48331 deletions(-)

Changes: xamarin/xamarin-android-api-compatibility@a61271e...50a3c52

        $ git diff --shortstat a61271e0...50a3c52d
         1 file changed, 2 insertions(+), 791 deletions(-)

Fixes: #3619

Context: https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1005448
Context: https://devdiv.visualstudio.com/DefaultCollection/DevDiv/_workitems/edit/967582
Context: https://github.com/dotnet/coreclr/issues/26370
Context: https://github.com/dotnet/coreclr/issues/26479
Context: https://github.com/dotnet/corefx/issues/40455
Context: https://github.com/dotnet/corefx/issues/40578
Context: mono/mono#7377
Context: mono/mono#12421
Context: mono/mono#12586
Context: mono/mono#14080
Context: mono/mono#14725
Context: mono/mono#14772
Context: mono/mono#15261
Context: mono/mono#15262
Context: mono/mono#15263
Context: mono/mono#15307
Context: mono/mono#15308
Context: mono/mono#15310
Context: mono/mono#15646
Context: mono/mono#15687
Context: mono/mono#15805
Context: mono/mono#15992
Context: mono/mono#15994
Context: mono/mono#15999
Context: mono/mono#16032
Context: mono/mono#16034
Context: mono/mono#16046
Context: mono/mono#16192
Context: mono/mono#16308
Context: mono/mono#16310
Context: mono/mono#16369
Context: mono/mono#16380
Context: mono/mono#16381
Context: mono/mono#16395
Context: mono/mono#16411
Context: mono/mono#16415
Context: mono/mono#16486
Context: mono/mono#16570
Context: mono/mono#16605
Context: mono/mono#16616
Context: mono/mono#16689
Context: mono/mono#16701
Context: mono/mono#16712
Context: mono/mono#16742
Context: mono/mono#16759
Context: mono/mono#16803
Context: mono/mono#16808
Context: mono/mono#16824
Context: mono/mono#16876
Context: mono/mono#16879
Context: mono/mono#16918
Context: mono/mono#16943
Context: mono/mono#16950
Context: mono/mono#16974
Context: mono/mono#17004
Context: mono/mono#17017
Context: mono/mono#17038
Context: mono/mono#17040
Context: mono/mono#17083
Context: mono/mono#17084
Context: mono/mono#17133
Context: mono/mono#17139
Context: mono/mono#17151
Context: mono/mono#17180
Context: mono/mono#17278
Context: mono/mono#17549
Context: mono/mono#17569
Context: mono/mono#17665
Context: mono/mono#17687
Context: mono/mono#17737
Context: mono/mono#17790
Context: mono/mono#17924
Context: mono/mono#17931
Context: https://github.com/mono/mono/issues/26758
Context: https://github.com/mono/mono/issues/37913
Context: xamarin/xamarin-macios#7005
jonpryor pushed a commit to dotnet/android that referenced this issue Dec 3, 2019
Changes: mono/api-snapshot@fc50bc4...45a61d9

        $ git diff --shortstat fc50bc4f...45a61d93
         22 files changed, 775 insertions(+), 474 deletions(-)

Changes: dotnet/cecil@a6c8f5e...a6a7f5c

        $ git diff --shortstat a6c8f5e1...a6a7f5c0
         55 files changed, 818 insertions(+), 530 deletions(-)

Changes: mono/corefx@1f87de3...49f1c45

        $ git diff --shortstat e4f7102b...49f1c453
         38 files changed, 1171 insertions(+), 419 deletions(-)

Changes: dotnet/linker@ebe2a1f...e8d054b

        $ git diff --shortstat ebe2a1f4...e8d054bf
         137 files changed, 5360 insertions(+), 1781 deletions(-)

Changes: mono/mono@8946e49...18920a8

        $ git diff --shortstat 8946e49a...18920a83
         1811 files changed, 47240 insertions(+), 48331 deletions(-)

Changes: xamarin/xamarin-android-api-compatibility@a61271e...50a3c52

        $ git diff --shortstat a61271e0...50a3c52d
         1 file changed, 2 insertions(+), 791 deletions(-)

Fixes: #3619

Context: https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1005448
Context: https://devdiv.visualstudio.com/DefaultCollection/DevDiv/_workitems/edit/967582
Context: https://github.com/dotnet/coreclr/issues/26370
Context: https://github.com/dotnet/coreclr/issues/26479
Context: https://github.com/dotnet/corefx/issues/40455
Context: https://github.com/dotnet/corefx/issues/40578
Context: mono/mono#7377
Context: mono/mono#12421
Context: mono/mono#12586
Context: mono/mono#14080
Context: mono/mono#14725
Context: mono/mono#14772
Context: mono/mono#15261
Context: mono/mono#15262
Context: mono/mono#15263
Context: mono/mono#15307
Context: mono/mono#15308
Context: mono/mono#15310
Context: mono/mono#15646
Context: mono/mono#15687
Context: mono/mono#15805
Context: mono/mono#15992
Context: mono/mono#15994
Context: mono/mono#15999
Context: mono/mono#16032
Context: mono/mono#16034
Context: mono/mono#16046
Context: mono/mono#16192
Context: mono/mono#16308
Context: mono/mono#16310
Context: mono/mono#16369
Context: mono/mono#16380
Context: mono/mono#16381
Context: mono/mono#16395
Context: mono/mono#16411
Context: mono/mono#16415
Context: mono/mono#16486
Context: mono/mono#16570
Context: mono/mono#16605
Context: mono/mono#16616
Context: mono/mono#16689
Context: mono/mono#16701
Context: mono/mono#16712
Context: mono/mono#16742
Context: mono/mono#16759
Context: mono/mono#16803
Context: mono/mono#16808
Context: mono/mono#16824
Context: mono/mono#16876
Context: mono/mono#16879
Context: mono/mono#16918
Context: mono/mono#16943
Context: mono/mono#16950
Context: mono/mono#16974
Context: mono/mono#17004
Context: mono/mono#17017
Context: mono/mono#17038
Context: mono/mono#17040
Context: mono/mono#17083
Context: mono/mono#17084
Context: mono/mono#17133
Context: mono/mono#17139
Context: mono/mono#17151
Context: mono/mono#17180
Context: mono/mono#17278
Context: mono/mono#17549
Context: mono/mono#17569
Context: mono/mono#17665
Context: mono/mono#17687
Context: mono/mono#17737
Context: mono/mono#17790
Context: mono/mono#17924
Context: mono/mono#17931
Context: https://github.com/mono/mono/issues/26758
Context: https://github.com/mono/mono/issues/37913
Context: xamarin/xamarin-macios#7005
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants