[Mono-bugs] [Bug 586870] New: Exception when serializing empty byte array generated from empty string

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Mar 9 20:37:23 EST 2010


http://bugzilla.novell.com/show_bug.cgi?id=586870

http://bugzilla.novell.com/show_bug.cgi?id=586870#c0


           Summary: Exception when serializing empty byte array generated
                    from empty string
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.6.x
          Platform: x86-64
        OS/Version: Ubuntu
            Status: NEW
          Severity: Critical
          Priority: P5 - None
         Component: CORLIB
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: greg.smolyn at strangeloopnetworks.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


Created an attachment (id=347481)
 --> (http://bugzilla.novell.com/attachment.cgi?id=347481)
Test case to demonstrate bug in serializing

User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_2; en-us)
AppleWebKit/533.2+ (KHTML, like Gecko) Version/4.0.4 Safari/531.21.10

This is a bit confusing, but has a simple repro case, which I _think_ lends
itself to a possibly very severe bug.

When we serialize a byte[] array that is returned from Encoding.GetBytes(""),
it will throw an exception if we pass it through the DeflateStream.

I stepped through the zlib-helper, and WriteZStream ended up failing when it
gets a buf of 0.

I've created a repro case, however this _only_ happens when we use
Encoding.X.GetBytes("") to generate the byte[] array.  If we simply assign
byte[] foo = new Byte[0] and attempt to serialize that, everything is
absolutely fine.

So the worrisome part is how the byte arrays seem to be different somehow
internally, where WriteZStream is given a null ptr in the Encoding.GetBytes
case.  
This I imagine is somehow in the BinaryFormatter, which is dishing out this
null ptr?

Here's the stack trace:

Unhandled Exception: System.IO.IOException: Invalid argument(s) WriteInternal
  at System.IO.Compression.DeflateStream.CheckResult (Int32 result,
System.String where) [0x000a7] in
/home/strangeloop/src/mono/mono-2.6.1/mcs/class/System/System.IO.Compression/DeflateStream.cs:280 
  at System.IO.Compression.DeflateStream.WriteInternal (System.Byte[] array,
Int32 offset, Int32 count) [0x0003a] in
/home/strangeloop/src/mono/mono-2.6.1/mcs/class/System/System.IO.Compression/DeflateStream.cs:221 
  at System.IO.Compression.DeflateStream.Write (System.Byte[] src, Int32
src_offset, Int32 count) [0x00067] in
/home/strangeloop/src/mono/mono-2.6.1/mcs/class/System/System.IO.Compression/DeflateStream.cs:241 
  at System.IO.Compression.GZipStream.Write (System.Byte[] src, Int32
src_offset, Int32 count) [0x00000] in
/home/strangeloop/src/mono/mono-2.6.1/mcs/class/System/System.IO.Compression/GZipStream.cs:66 
  at System.IO.BinaryWriter.Write (System.Byte[] buffer) [0x0002c] in
/home/strangeloop/src/mono/mono-2.6.1/mcs/class/corlib/System.IO/BinaryWriter.cs:130 
  at
System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WritePrimitiveTypeArray
(System.IO.BinaryWriter writer, Int64 id, System.Array array) [0x000b1] in
/home/strangeloop/src/mono/mono-2.6.1/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectWriter.cs:554 
  at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteArray
(System.IO.BinaryWriter writer, Int64 id, System.Array array) [0x00077] in
/home/strangeloop/src/mono/mono-2.6.1/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectWriter.cs:466 
  at
System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteObjectInstance
(System.IO.BinaryWriter writer, System.Object obj, Boolean isValueObject)
[0x0004f] in
/home/strangeloop/src/mono/mono-2.6.1/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectWriter.cs:290 
  at
System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteQueuedObjects
(System.IO.BinaryWriter writer) [0x00005] in
/home/strangeloop/src/mono/mono-2.6.1/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectWriter.cs:271 
  at
System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteObjectGraph
(System.IO.BinaryWriter writer, System.Object obj,
System.Runtime.Remoting.Messaging.Header[] headers) [0x0001f] in
/home/strangeloop/src/mono/mono-2.6.1/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectWriter.cs:256 
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize
(System.IO.Stream serializationStream, System.Object graph,
System.Runtime.Remoting.Messaging.Header[] headers) [0x000a4] in
/home/strangeloop/src/mono/mono-2.6.1/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/BinaryFormatter.cs:230 
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize
(System.IO.Stream serializationStream, System.Object graph) [0x00000] in
/home/strangeloop/src/mono/mono-2.6.1/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/BinaryFormatter.cs:209 
  at TestSerialize.MainClass.Main (System.String[] args) [0x00024] in
/home/strangeloop/TestSerialize/Main.cs:19 


Reproducible: Always

Steps to Reproduce:
1. Open up attached test
2. Run Test
3.
Actual Results:  
IO Exception

Expected Results:  
No exception

This is a very high priority bug for us, and we are currently having to hack
around it in production code.  We're always glad to test or run from SVN trunk
if we need to.

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list