Bug 53296 - Latin1Encoding throws exception on Mono when it doesn't on MS.NET
Summary: Latin1Encoding throws exception on Mono when it doesn't on MS.NET
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib (show other bugs)
Version: 4.8.0 (C9)
Hardware: PC All
: --- normal
Target Milestone: Future Release
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-03-14 02:07 UTC by Alex Earl
Modified: 2017-10-17 12:59 UTC (History)
4 users (show)

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


Attachments
Reproduction case for issue. (2.62 KB, text/plain)
2017-03-14 02:07 UTC, Alex Earl
Details


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:
Status:
RESOLVED FIXED

Description Alex Earl 2017-03-14 02:07:30 UTC
Created attachment 20297 [details]
Reproduction case for issue.

In IronPython, we have a test that encodes various strings with different encodings to test that they correctly map to CPython's way of doing things. We are getting an exception from Latin1Encoding.InternalGetBytes. Attached is a repro case. This does NOT throw an exception on MS.NET
Comment 1 Alex Earl 2017-03-14 03:50:57 UTC
This is the exception I get on mono.

Unhandled Exception:
System.ArgumentException: Arg_InsufficientSpace
  at System.Text.Latin1Encoding.InternalGetBytes (System.Char* chars, System.Int32 charLength, System.Int32 charIndex, System.Int32 charCount, System.Byte[] bytes, System.Int32 byteIndex, System.Text.EncoderFallbackBuffer& buffer, System.Char[]& fallback_chars) [0x0009c] in <f712f98eb8e445c8918edaf595bbe465>:0 
  at System.Text.Latin1Encoding.GetBytes (System.Char[] chars, System.Int32 charIndex, System.Int32 charCount, System.Byte[] bytes, System.Int32 byteIndex, System.Text.EncoderFallbackBuffer& buffer, System.Char[]& fallback_chars) [0x0002e] in <f712f98eb8e445c8918edaf595bbe465>:0 
  at System.Text.Latin1Encoding.InternalGetBytes (System.Char* chars, System.Int32 charLength, System.Int32 charIndex, System.Int32 charCount, System.Byte[] bytes, System.Int32 byteIndex, System.Text.EncoderFallbackBuffer& buffer, System.Char[]& fallback_chars) [0x001b5] in <f712f98eb8e445c8918edaf595bbe465>:0 
  at System.Text.Latin1Encoding.GetBytes (System.String s, System.Int32 charIndex, System.Int32 charCount, System.Byte[] bytes, System.Int32 byteIndex, System.Text.EncoderFallbackBuffer& buffer, System.Char[]& fallback_chars) [0x00024] in <f712f98eb8e445c8918edaf595bbe465>:0 
  at System.Text.Latin1Encoding.GetBytes (System.String s, System.Int32 charIndex, System.Int32 charCount, System.Byte[] bytes, System.Int32 byteIndex) [0x00004] in <f712f98eb8e445c8918edaf595bbe465>:0 
  at System.Text.Encoding.GetBytes (System.String s) [0x00033] in <f712f98eb8e445c8918edaf595bbe465>:0 
  at Program.Main (System.String[] args) [0x00020] in <7ccdc01aec674125bc10f7c103117b0e>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentException: Arg_InsufficientSpace
  at System.Text.Latin1Encoding.InternalGetBytes (System.Char* chars, System.Int32 charLength, System.Int32 charIndex, System.Int32 charCount, System.Byte[] bytes, System.Int32 byteIndex, System.Text.EncoderFallbackBuffer& buffer, System.Char[]& fallback_chars) [0x0009c] in <f712f98eb8e445c8918edaf595bbe465>:0 
  at System.Text.Latin1Encoding.GetBytes (System.Char[] chars, System.Int32 charIndex, System.Int32 charCount, System.Byte[] bytes, System.Int32 byteIndex, System.Text.EncoderFallbackBuffer& buffer, System.Char[]& fallback_chars) [0x0002e] in <f712f98eb8e445c8918edaf595bbe465>:0 
  at System.Text.Latin1Encoding.InternalGetBytes (System.Char* chars, System.Int32 charLength, System.Int32 charIndex, System.Int32 charCount, System.Byte[] bytes, System.Int32 byteIndex, System.Text.EncoderFallbackBuffer& buffer, System.Char[]& fallback_chars) [0x001b5] in <f712f98eb8e445c8918edaf595bbe465>:0 
  at System.Text.Latin1Encoding.GetBytes (System.String s, System.Int32 charIndex, System.Int32 charCount, System.Byte[] bytes, System.Int32 byteIndex, System.Text.EncoderFallbackBuffer& buffer, System.Char[]& fallback_chars) [0x00024] in <f712f98eb8e445c8918edaf595bbe465>:0 
  at System.Text.Latin1Encoding.GetBytes (System.String s, System.Int32 charIndex, System.Int32 charCount, System.Byte[] bytes, System.Int32 byteIndex) [0x00004] in <f712f98eb8e445c8918edaf595bbe465>:0 
  at System.Text.Encoding.GetBytes (System.String s) [0x00033] in <f712f98eb8e445c8918edaf595bbe465>:0 
  at Program.Main (System.String[] args) [0x00020] in <7ccdc01aec674125bc10f7c103117b0e>:0
Comment 2 Alexander Köplinger [MSFT] 2017-10-16 20:40:41 UTC
This will be fixed with https://github.com/mono/mono/pull/5792, thanks!
Comment 3 Alexander Köplinger [MSFT] 2017-10-17 12:59:11 UTC
PR was merged.