-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
System.Text.Decoder throws ArgumentOutOfRangeException when it should no... #580
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… not. Fixes Bug mono#10789 Similar to previously reported bug mono#6404, according to the documentation at http://msdn.microsoft.com/en-us/library/h6w985hz.aspx, System.Text.Encoder throws ArgumentOutOfRangeExceptions when it should not. From the documentation, an ArgumentOutOfRangeException should be thrown when: charIndex, charCount, byteIndex, or byteCount is less than zero. -or- The length of chars - charIndex is less than charCount. -or- The length of bytes - byteIndex is less than byteCount. To reproduce, run the following code: int charsUsed, bytesUsed; bool completed; byte[] bytes = new byte[4096]; char[] chars = new char[4096]; System.Text.Encoding.UTF8.GetDecoder().Convert(bytes, 0, 0, chars, 4096, 0, false, out bytesUsed, out charsUsed, out completed); Expected: The code runs, charsUsed equals zero, bytesUsed equals zero and completed is true. Actual: Mono throws an ArgumentOutOfRangeException for charIndex. There are also other behavioral differences between Mono and Microsoft's implementation for the GetChars(Byte[], Int32, Int32, Char[], Int32, Boolean) method, such as: byte[] bytes = new byte[4096]; char[] chars = new char[10]; int charactersWritten = System.Text.Encoding.UTF8.GetDecoder().GetChars(bytes, 0, 0, chars, 10, false); On Mono, this results in an ArgumentOutOfRangeException for charIndex, where for Microsoft charactersWritten = 0. Similarly: byte[] bytes = new byte[4096]; char[] chars = new char[10]; int charactersWritten = System.Text.Encoding.UTF8.GetDecoder().GetChars(bytes, 0, 4096, chars, 10, false); On Mono, this results in the same ArgumentOutOfRangeException for charIndex, where Microsoft throws and ArgumentException since "chars does not have enough capacity from charIndex to the end of the array to accommodate the resulting characters."
Could you re-submit the request, there is conflict probably in test files |
Request resubmitted, #584 |
lambdageek
added a commit
that referenced
this pull request
Apr 25, 2017
* Check strong names on a couple more codepaths during assembly loading. Fixes [bugzilla #580](https://bugzilla.xamarin.com/show_bug.cgi?id=580) and [bugzilla #55436](https://bugzilla.xamarin.com/show_bug.cgi?id=55436) * Add `--apply-bindings=FILE` option. Allows us to specify a configuration file for assembly binding redirections when AOTing. * Use the above flag when AOTing `System.ReflectionMetadata.dll` to pick up `csc.exe.config` * Add all the Facades to the `framework_assemblies` list in the runtime. Facade and non-Facade framework assemblies behave differently: * for Facades, don't do any version remapping, and any version is okay. * for non-Facades, consult the version map to remap depdending on the --runtime used.
lambdageek
added a commit
that referenced
this pull request
Apr 26, 2017
* Check strong names on a couple more codepaths during assembly loading. Fixes [bugzilla #580](https://bugzilla.xamarin.com/show_bug.cgi?id=580) and [bugzilla #55436](https://bugzilla.xamarin.com/show_bug.cgi?id=55436) * Add `--apply-bindings=FILE` option. Allows us to specify a configuration file for assembly binding redirections when AOTing. * Use the above flag when AOTing `System.ReflectionMetadata.dll` to pick up `csc.exe.config` * Add all the Facades to the `framework_assemblies` list in the runtime. Facade and non-Facade framework assemblies behave differently: * for Facades, don't do any version remapping, and any version is okay. * for non-Facades, consult the version map to remap depdending on the --runtime used.
picenka21
pushed a commit
to picenka21/runtime
that referenced
this pull request
Feb 18, 2022
* Check strong names on a couple more codepaths during assembly loading. Fixes [bugzilla mono/mono#580](https://bugzilla.xamarin.com/show_bug.cgi?id=580) and [bugzilla mono/mono#55436](https://bugzilla.xamarin.com/show_bug.cgi?id=55436) * Add `--apply-bindings=FILE` option. Allows us to specify a configuration file for assembly binding redirections when AOTing. * Use the above flag when AOTing `System.ReflectionMetadata.dll` to pick up `csc.exe.config` * Add all the Facades to the `framework_assemblies` list in the runtime. Facade and non-Facade framework assemblies behave differently: * for Facades, don't do any version remapping, and any version is okay. * for non-Facades, consult the version map to remap depdending on the --runtime used. Commit migrated from mono/mono@25bcd22
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
...t. Fixes Bug #10789
Similar to previously reported bug #6404, according to the documentation at http://msdn.microsoft.com/en-us/library/h6w985hz.aspx, System.Text.Encoder throws ArgumentOutOfRangeExceptions when it should not. From the documentation, an ArgumentOutOfRangeException should be thrown when:
charIndex, charCount, byteIndex, or byteCount is less than zero.
-or-
The length of chars - charIndex is less than charCount.
-or-
The length of bytes - byteIndex is less than byteCount.
To reproduce, run the following code:
int charsUsed, bytesUsed;
bool completed;
byte[] bytes = new byte[4096];
char[] chars = new char[4096];
System.Text.Encoding.UTF8.GetDecoder().Convert(bytes, 0, 0, chars, 4096, 0, false, out bytesUsed, out charsUsed, out completed);
Expected:
The code runs, charsUsed equals zero, bytesUsed equals zero and completed is true.
Actual:
Mono throws an ArgumentOutOfRangeException for charIndex.
There are also other behavioral differences between Mono and Microsoft's implementation for the GetChars(Byte[], Int32, Int32, Char[], Int32, Boolean) method, such as:
byte[] bytes = new byte[4096];
char[] chars = new char[10];
int charactersWritten = System.Text.Encoding.UTF8.GetDecoder().GetChars(bytes, 0, 0, chars, 10, false);
On Mono, this results in an ArgumentOutOfRangeException for charIndex, where for Microsoft charactersWritten = 0.
Similarly:
byte[] bytes = new byte[4096];
char[] chars = new char[10];
int charactersWritten = System.Text.Encoding.UTF8.GetDecoder().GetChars(bytes, 0, 4096, chars, 10, false);
On Mono, this results in the same ArgumentOutOfRangeException for charIndex, where Microsoft throws and ArgumentException since "chars does not have enough capacity from charIndex to the end of the array to accommodate the resulting characters."