[Mono-bugs] [Bug 441443] New: Deserialize() seeks to illegal stream position

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Nov 4 07:04:49 EST 2008


https://bugzilla.novell.com/show_bug.cgi?id=441443


           Summary: Deserialize() seeks to illegal stream position
           Product: Mono: Class Libraries
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: System
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: michi at zeroc.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


I have a class that implements System.IO.Stream. I use this class successfully
to serialize and deserialize class instances with .NET.

When using the same class with Mono, I get an exception (raised by my class
implementation) during deserialization. Turns out that the Deserialize() ends
up setting the Position property of the stream to -1. My stream implementation
throws an exception in response because seeking to a byte offset preceeding the
start of the stream does not make sense.

The MS implementation of Deserialize doesn't have this problem, and my class
works fine with .NET 3.5, so I suspect a bug in Deserialize().

Here is a stack trace (taken on OS X):

Ice.MarshalException
    reason = "cannot deserialize object:"
  at IceInternal.BasicStream.readSerializable () [0x00000] 
  at Test.MyClass.opSerialSmallCSharp___ (Test.MyClass obj__,
IceInternal.Incoming inS__, Ice.Current current__) [0x00000] 
  at Test.MyClass.dispatch__ (IceInternal.Incoming inS__, Ice.Current
current__) [0x00000] 
  at IceInternal.Incoming.invoke (IceInternal.ServantManager servantManager)
[0x00000] 
Caused by: System.ArgumentOutOfRangeException: position must be non-negative
Parameter name: pos
-1
  at IceInternal.ByteBuffer.position (Int32 pos) [0x00000] 
  at IceInternal.BasicStream.pos (Int32 n) [0x00000] 
  at IceInternal.StreamWrapper.Seek (Int64 offset, SeekOrigin origin) [0x00000] 
  at IceInternal.StreamWrapper.set_Position (Int64 value) [0x00000] 
  at System.IO.BinaryReader.PeekChar () [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 IceInternal.BasicStream.readSerializable () [0x00000] 

I've verified that the root cause of the problem is the call to set_Position,
with an argument of -1.

My implementation of set_position looks like this:

public override long Position
        {
            get
            {
                checkDisposed();
                return pos_;
            }

            set
            {
                Seek(value, SeekOrigin.Begin);
            }
        }
The value for the set method is -1, and that is rejected by my Seek
implementation because seeking to an offset preceding the beginning of the
stream does not make sense.

I believe my implementation is correct: the argument for setPosition should be
an absolute offset, not a relative one.

Please let me know if you need more info.

Thanks,

Michi.


-- 
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