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@lists.ximian.com
        ReportedBy: [EMAIL PROTECTED]
         QAContact: mono-bugs@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.
_______________________________________________
mono-bugs maillist  -  mono-bugs@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-bugs

Reply via email to