[Mono-bugs] [Bug 82460][Nor] New - UnixEnvironment.MachineName throws exceptions for long hostnames

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Thu Aug 16 16:53:53 EDT 2007

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 pierre.ostlund at gmail.com.


--- shadow/82460	2007-08-16 16:53:53.000000000 -0400
+++ shadow/82460.tmp.28627	2007-08-16 16:53:53.000000000 -0400
@@ -0,0 +1,63 @@
+Bug#: 82460
+Product: Mono: Class Libraries
+Version: 1.2
+OS Details: Ubuntu 7.04 (Feisty Fawn)
+Status: NEW   
+Priority: Normal
+Component: Mono.POSIX
+AssignedTo: miguel at ximian.com                            
+ReportedBy: pierre.ostlund at gmail.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+Summary: UnixEnvironment.MachineName throws exceptions for long hostnames
+The implementation of Mono.Unix.UnixEnvironment.MachineName is throwing an
+exception when the host name of a system is longer than or equal to 16
+Steps to reproduce the problem:
+1. Change system host name to something longer than or equal to 16
+characters. The host name "thisisaverynicehostname" will be used here.
+2. Compile and run this code:
+using System;
+using Mono.Unix;
+class Foo {
+       public static void Main (string[] args)
+       {
+               Console.WriteLine (UnixEnvironment.MachineName);
+       }
+(i.e. save it as test.cs and compile with: gmcs test.cs -r:Mono.Posix)
+Actual Results:
+Unhandled Exception: System.OutOfMemoryException: Out of memory
+  at <0x00000> <unknown method>
+  at (wrapper managed-to-native) System.String:InternalAllocateStr (int)
+  at System.Text.StringBuilder.InternalEnsureCapacity (Int32 size)
+[0x000b1] in
+  at System.Text.StringBuilder.set_Capacity (Int32 value) [0x00017] in
+  at Mono.Unix.UnixEnvironment.get_MachineName () [0x0000b] in
+  at Foo.Main (System.String[] args) [0x00000] 
+Expected Results:
+The text: "thisisaverynicehostname" should pe printed to terminal.
+How often does this happen? 
+Every time
+Additional Information:
+This bug has been confirmed on various systems and versions of mono
+(including SVN). I am using mono version as included with Ubuntu 7.04.

More information about the mono-bugs mailing list