[Mono-bugs] [Bug 79152][Nor] New - StringBuilder default ctor does not allocate internal string

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Thu Aug 24 04:26:44 EDT 2006


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by gert.driesen at pandora.be.

http://bugzilla.ximian.com/show_bug.cgi?id=79152

--- shadow/79152	2006-08-24 04:26:44.000000000 -0400
+++ shadow/79152.tmp.27618	2006-08-24 04:26:44.000000000 -0400
@@ -0,0 +1,81 @@
+Bug#: 79152
+Product: Mono: Class Libraries
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: CORLIB
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: gert.driesen at pandora.be               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: StringBuilder default ctor does not allocate internal string
+
+Apparently the default ctor of StringBuilder does not allocate the 
+internal string, and as a result you get an ArgumentOutOfRangeException 
+when pinvoking a function with marshalling to StringBuilder:
+
+Unhandled Exception: System.ArgumentOutOfRangeException: newLength as to 
+be <= length
+Parameter name: newLength
+  at System.String.InternalSetLength (Int32 newLength) [0x00000]
+  at System.Text.StringBuilder.ToString () [0x00000]
+  at Test.LookupSID (System.Byte[] sid, Boolean ansi) [0x00000]
+  at Test.Main () [0x00000]
+
+To reproduce, compile and run the attached repro on Windows.
+
+The repro will invoke both the unicode and ANSI versions of the win32 
+LookupAccountSid function.
+
+Expected result:
+================
+
+Administrators SID:
+
+*Unicode*
+#B1:14 / 14
+#B2:Administrators
+#B3:7 / 7
+#B4:BUILTIN
+*ANSI*
+#B1:14 / 14
+#B2:Administrators
+#B3:7 / 7
+#B4:BUILTIN
+
+System SID:
+
+*Unicode*
+#B1:6 / 6
+#B2:SYSTEM
+#B3:12 / 12
+#B4:NT AUTHORITY
+*ANSI*
+#B1:6 / 6
+#B2:SYSTEM
+#B3:12 / 12
+#B4:NT AUTHORITY
+
+Actual result:
+==============
+
+Administrators SID:
+
+*Unicode*
+#B1:14 / 14
+#B2:Administrators
+#B3:7 / 7
+
+Unhandled Exception: System.ArgumentOutOfRangeException: newLength as to 
+be <= length
+Parameter name: newLength
+  at System.String.InternalSetLength (Int32 newLength) [0x00000]
+  at System.Text.StringBuilder.ToString () [0x00000]
+  at Test.LookupSID (System.Byte[] sid, Boolean ansi) [0x00000]
+  at Test.Main () [0x00000]


More information about the mono-bugs mailing list