[Mono-bugs] [Bug 641821] New: [PATCH] version tolerant serialization fails with missing primitive typed members

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri Sep 24 18:48:43 EDT 2010



           Summary: [PATCH] version tolerant serialization fails with
                    missing primitive typed members
    Classification: Mono
           Product: Mono: Class Libraries
           Version: SVN
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: CORLIB
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: ambroff at lindenlab.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---

User-Agent:       Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/5343
(KHTML, like Gecko) Chrome/6.0.472.62 Safari/534.3

The attached patch includes an extension to the VTS tests that Andrés added
recently, which tests deserializing an Address object that contains a member of
type int called 'Id', as well as a fix to
System.Runtime.Serialization.Formatters.Binary.ObjectReader to make that test

It turns out that while the member was properly being ignored when the Address
type in the current domain doesn't have that member, the parser was not seeking
past the value to the next block in the stream, so it would try to read value
as the type metadata of the next block, which would normally be a
BinaryCommon.BinaryElement enum.

We tested deserializing an object serialized with Microsoft's implementation to
make sure that mono's ObjectWriter class wasn't writing bad data. The test case
works fine with Microsoft's implementation.

The patch to ObjectReader just has it read the value anyway and throw it away
if we know it's a primitive type, so that we seek to the next block of the
object stream.

Reproducible: Always

Actual Results:  
Without the patch to ObjectReader.cs, you get the following traceback when
running make -C mcs/class/corlib run-test-vts:

Unhandled Exception: System.Runtime.Serialization.SerializationException:
Unexpected binary element: 0
  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] in <filename unknown>:0 
  at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadValue
(System.IO.BinaryReader reader, System.Object parentObject, Int64
parentObjectId, System.Runtime.Serialization.SerializationInfo info,
System.Type valueType, System.String fieldName, System.Reflection.MemberInfo
memberInfo, System.Int32[] indices) [0x00000] in <filename unknown>:0

Note that the unexpected binary element "0" is from the value of the Id member
in the stream, which in the test is set to 0. If it's set to another value,
say, 9, the parser will get confused and think it's reading a
BinaryElement.ObjectReference, and then crash later.

If this patch looks safe, it can be pulled from my git repo.

Configure bugmail: https://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