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)

See Also:
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

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.

Note You need to log in before you can comment on or make changes to this bug.