[Mono-bugs] [Bug 79870][Nor] New - mono GMCS compiler and a serialization bug
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Wed Nov 8 16:09:16 EST 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 darkcarnival at bigfoot-web.dk.
http://bugzilla.ximian.com/show_bug.cgi?id=79870
--- shadow/79870 2006-11-08 16:09:16.000000000 -0500
+++ shadow/79870.tmp.12843 2006-11-08 16:09:16.000000000 -0500
@@ -0,0 +1,180 @@
+Bug#: 79870
+Product: Mono: Compilers
+Version: unspecified
+OS:
+OS Details: Ubuntu Edgy Eft (6.10)
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: C#
+AssignedTo: rharinath at novell.com
+ReportedBy: darkcarnival at bigfoot-web.dk
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: mono GMCS compiler and a serialization bug
+
+Description of Problem:
+Compiler used: gmcs (the NET2.0 specification compiler ? )
+((Won't trigger a bug on the mcs compiler))
+
+I use this piece of code and first I run it as is, it will do a
+serialization of an ArrayList named myArrayList which contains some
+WebProxy objects. Now when the code has run, a binary file called
+"serializationData2.dat" is created.
+
+When I comment "s.DoSerialize();" to prevent it from serializing anew and
+instead forcing it to read the old data written to the file, an error which
+seems to start from deep within the standard libraries. (The exact ouput is
+shown under "Actual Results")
+
+However, if you keep letting it serialize just before deserializing from
+the same file, no bug occurs.
+
+Read on at "Steps to reproduce the problem" to see for yourself.
+
+Code:
+----------------------------------------------------------------------
+using System;
+using System.Net;
+using System.Collections;
+using System.IO;
+
+using System.Runtime.Serialization;
+using System.Runtime.Serialization.Formatters.Binary;
+
+class SerializeTest
+{
+ public void DoSerialize() //save
+ {
+ Console.WriteLine("Inside the DoSerialize() function...");
+ ArrayList myArrayList = new ArrayList();
+ Console.WriteLine("ArrayList count: " + myArrayList.Count);
+ Console.WriteLine("ArrayList capacity: " + myArrayList.Capacity + "\n");
+ myArrayList.Add( new WebProxy("http://127.0.0.1:80", true));
+ myArrayList.Add( new WebProxy("http://127.0.0.2:80", true));
+ myArrayList.Add( new WebProxy("http://127.0.0.3:80", true));
+ Console.WriteLine("\nArrayList count: " + myArrayList.Count);
+ Console.WriteLine("ArrayList capacity: " + myArrayList.Capacity);
+
+ //Begin serialization process:
+ FileInfo file = new FileInfo("serializationData2.dat");
+ Stream fileStream = file.Open(FileMode.Create);
+ BinaryFormatter writer = new BinaryFormatter();
+ writer.Serialize(fileStream, myArrayList);
+ fileStream.Close();
+ }
+
+ public void DeSerialize() //load
+ {
+ //create something to store the result of the deserialization
+ ArrayList myDeSerializedArrayList = new ArrayList();
+
+ Console.WriteLine("\nInside the DeSerialize() function...");
+ FileInfo file = new FileInfo("serializationData2.dat");
+ Stream fileStream = file.Open(FileMode.Open);
+ BinaryFormatter reader = new BinaryFormatter();
+ myDeSerializedArrayList = (ArrayList)reader.Deserialize(fileStream);
+
+ //Print out the values of the different instances of ArrayClass
+ for ( int i = 0; i < myDeSerializedArrayList.Count; i++)
+ { //must explicitly cast the ArrayList object to my classtype to use the
+member methods!
+ Console.WriteLine("Proxy object found!");
+ }
+ }
+}
+
+
+class MainClass
+{
+ public static void Main()
+ {
+ SerializeTest s;
+ s = new SerializeTest();
+ s.DoSerialize(); //this is the line to comment out to get the bug to
+appear (after having run it like this 1 time, READ description)
+ s.DeSerialize();
+ }
+}
+--------------------------------------------------------------------------
+
+
+Steps to reproduce the problem:
+1. take the code and save it as serialization.cs
+2. Compile like so: gmcs serialization.cs /out:test.exe
+3. Run the executeable: mono test.exe
+4. Comment DoSerialize(); out (inside the Main method)
+5. Recompile: gmcs serialization.cs /out:test.exe
+6. Run: mono text.exe
+
+Actual Results:
+$ mono test.exe
+
+Inside the DeSerialize() function...
+
+Unhandled Exception: System.IO.FileNotFoundException: System : System
+ at <0x00000> <unknown method>
+ at (wrapper managed-to-native) System.AppDomain:LoadAssembly
+(string,System.Security.Policy.Evidence,bool)
+ at System.AppDomain.Load (System.String assemblyString) [0x00000]
+ at (wrapper remoting-invoke-with-check) System.AppDomain:Load (string)
+ at System.Reflection.Assembly.Load (System.String assemblyString) [0x00000]
+ at
+System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetDeserializationType
+(Int64 assemblyId, System.String className) [0x00000]
+ at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadType
+(System.IO.BinaryReader reader, TypeTag code) [0x00000]
+ at
+System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadTypeMetadata
+(System.IO.BinaryReader reader, Boolean isRuntimeObject, Boolean
+hasTypeInfo) [0x00000]
+ at
+System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObjectInstance
+(System.IO.BinaryReader reader, Boolean isRuntimeObject, Boolean
+hasTypeInfo, System.Int64 objectId, System.Object value,
+System.Runtime.Serialization.SerializationInfo info) [0x00000]
+ at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObject
+(BinaryElement element, System.IO.BinaryReader reader, System.Int64
+objectId, System.Object value,
+System.Runtime.Serialization.SerializationInfo info) [0x00000]
+ at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObject
+(BinaryElement element, System.IO.BinaryReader reader, System.Int64
+objectId, System.Object value,
+System.Runtime.Serialization.SerializationInfo info) [0x00000]
+ at
+System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadNextObject
+(System.IO.BinaryReader reader) [0x00000]
+ at
+System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObjectGraph
+(System.IO.BinaryReader reader, Boolean readHeaders, System.Object result,
+System.Runtime.Remoting.Messaging.Header[] headers) [0x00000]
+ at
+System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.NoCheckDeserialize
+(System.IO.Stream serializationStream,
+System.Runtime.Remoting.Messaging.HeaderHandler handler) [0x00000]
+ at
+System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize
+(System.IO.Stream serializationStream) [0x00000]
+ at SerializeTest.DeSerialize () [0x00000]
+ at MainClass.Main () [0x00000]
+
+Expected Results:
+mono test.exe
+
+Inside the DeSerialize() function...
+Proxy object found!
+Proxy object found!
+Proxy object found!
+
+
+How often does this happen?
+Always (when using the gmcs compiler, mcs will make it run as expected!)
+
+Additional Information:
+*First bug submit ever, so please bear with me if things aren't perfect :/
+
+*Keyworded it parity because doing the same steps with the same code on a
+Windows pc with the csc compiler from MS produces the expected results as well.
More information about the mono-bugs
mailing list