[Mono-bugs] [Bug 71938][Nor] New - Problem with GetCommandLineArgs / possible memory corruption

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Fri, 28 Jan 2005 19:01:18 -0500 (EST)


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 sebastien@ximian.com.

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

--- shadow/71938	2005-01-28 19:01:18.000000000 -0500
+++ shadow/71938.tmp.22592	2005-01-28 19:01:18.000000000 -0500
@@ -0,0 +1,116 @@
+Bug#: 71938
+Product: Mono: Class Libraries
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: sebastien@ximian.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Problem with GetCommandLineArgs / possible memory corruption
+
+Description of Problem:
+Found a problem in GetCommandLineArgs when doing unit tests. There seems to
+be a (possible) memory corruption when using it with nunit - or at least
+the results are bad.
+
+
+Steps to reproduce the problem:
+1. Compile the following source code with:
+> mcs bug.cs
+
+using System;
+ 
+#if UNIT_TEST
+using NUnit.Framework;
+ 
+[TestFixture]
+public class Library {
+ 
+        [Test]
+        public void GetCommandLineArgs ()
+#else
+public class Program {
+ 
+        static public void Main ()
+#endif
+        {
+                string[] args = Environment.GetCommandLineArgs ();
+                if (args == null) {
+                        Console.WriteLine ("NULL");
+                } else {
+                        Console.WriteLine ("Length {0}", args.Length);
+                        foreach (string arg in args) {
+                                Console.WriteLine (arg);
+                        }
+                }
+        }
+}
+
+
+2. Execute with mono
+> mono bug.exe
+
+Length 1
+/home/poupou/src/bugzilla/bug.exe
+
+3. Now compile as a library for unit testing
+> mcs bug.cs /r:nunit.framework.dll /d:UNIT_TEST /target:library
+
+4. Execute with mono/nunit-console
+> mono ~/svn/mcs/class/lib/default/nunit-console.exe bug.dll
+
+
+Actual Results:
+NUnit version 2.2.0
+Copyright (C) 2002-2003 James W. Newkirk, Michael C. Two, Alexei A.
+Vorontsov, Charlie Poole.
+Copyright (C) 2000-2003 Philip Craig.
+All Rights Reserved.
+ 
+OS Version: Unix 2.6.8.717    Mono Version: 1.1.4322.573
+ 
+.Length 0
+ 
+ 
+Tests run: 1, Failures: 0, Not run: 0, Time: 0.037109 seconds
+
+
+
+Expected Results:
+Same as running as an EXE
+
+
+How often does this happen? 
+Always
+
+
+Additional Information:
+* A very similar code in another (not committed) unit test results in
+
+1)
+MonoTests.System.IO.Isolated.Tests.IsolatedStorageFileTest.GetUserStoreForDomain
+: System.OutOfMemoryException : Out of memory.
+in (unmanaged) 0x80af23c
+in <0x00004> (wrapper managed-to-native) System.String:InternalToUpper
+(System.Globalization.CultureInfo)
+in [0x00006] (at /home/poupou/svn/mcs/class/corlib/System/String.cs:781)
+System.String:ToUpper ()
+in [0x000da] (at
+/home/poupou/svn/mcs/class/corlib/Test/System.IO.IsolatedStorage/IsolatedStorageFileTest.cs:96)
+MonoTests.System.IO.Isolated.Tests.IsolatedStorageFileTest:GetUserStoreForDomain
+()
+
+Obviously something is wrong in later.
+
+After updating the code to showing the args.Length on the console, I got
+the following:
+
+.args.Length      135019024