Bug 5833 - Mono 2.11 CRASH on "string".Split('\0')
Summary: Mono 2.11 CRASH on "string".Split('\0')
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: master
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-06-22 23:19 UTC by James Bellinger
Modified: 2012-06-23 05:01 UTC (History)
2 users (show)

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


Attachments
Zip containing a solution and project to test (19.93 KB, application/zip)
2012-06-22 23:19 UTC, James Bellinger
Details
Second test, showing REG_MULTI_SZ now being broken (19.71 KB, application/zip)
2012-06-23 00:31 UTC, James Bellinger
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 James Bellinger 2012-06-22 23:19:58 UTC
Created attachment 2106 [details]
Zip containing a solution and project to test

Hello.

Just downloaded the 2.11 beta for Windows.
This is a new bug to 2.11. 2.10 string.Spit worked fine.

Output of the program under Mono 2.11 is:

mono --debug C:\code\src\monotest\StringSplitRegression
\StringSplitRegression\bin\Debug\StringSplitRegression.exe

Works:
Hello
World
Test
Mono bug:

Unhandled Exception: OutOfMemoryException
[ERROR] FATAL UNHANDLED EXCEPTION: System.OutOfMemoryException: Out of memory
  at (wrapper managed-to-native) string:InternalAllocateStr (int)
  at System.String.SubstringUnchecked (Int32 startIndex, Int32 length) [0x00000] in <filename unknown>:0
  at System.String.SplitByCharacters (System.Char[] sep, Int32 count, Boolean removeEmpty) [0x00000] in <filename unknow
n>:0
  at System.String.Split (System.Char[] separator, Int32 count, StringSplitOptions options) [0x00000] in <filename unkno
wn>:0
  at System.String.Split (System.Char[] separator) [0x00000] in <filename unknown>:0
  at StringSplitRegression.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0

This occurs if you split on a null character.
The "Works" section splits on \x0001 instead.
Comment 1 James Bellinger 2012-06-22 23:34:49 UTC
Here is a better stack trace:

Works:
Hello
World
Test

Mono bug:

Unhandled Exception: OutOfMemoryException
[ERROR] FATAL UNHANDLED EXCEPTION: System.OutOfMemoryException: Out of memory
  at (wrapper managed-to-native) string:InternalAllocateStr (int)
  at System.String.SubstringUnchecked (Int32 startIndex, Int32 length) [0x0000c] in C:\cygwin\sources\mono\mcs\class\cor
lib\System\String.cs:458
  at System.String.SplitByCharacters (System.Char[] sep, Int32 count, Boolean removeEmpty) [0x001bd] in C:\cygwin\source
s\mono\mcs\class\corlib\System\String.cs:397
  at System.String.Split (System.Char[] separator, Int32 count, StringSplitOptions options) [0x0007c] in C:\cygwin\sourc
es\mono\mcs\class\corlib\System\String.cs:234
  at System.String.Split (System.Char[] separator) [0x00000] in C:\cygwin\sources\mono\mcs\class\corlib\System\String.cs
:203
  at StringSplitRegression.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
Comment 2 James Bellinger 2012-06-23 00:22:16 UTC
Among other things this bug breaks REG_MULTI_SZ in RegistryKey.
Comment 3 James Bellinger 2012-06-23 00:31:00 UTC
Created attachment 2107 [details]
Second test, showing REG_MULTI_SZ now being broken

Initially I'd thought it was just my code broken by this bug.
However, this demonstrates that RegistryKey MultiString is now broken as well.

On 2.10.8, the attached code produces

A
B
C

Press any key

On 2.11, it is an OutOfMemoryException.
Comment 4 Marek Safar 2012-06-23 05:01:50 UTC
Already fixed in master