[Mono-bugs] [Bug 670974] Race condition in deserialization process

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Feb 14 04:51:17 EST 2011



Atsushi Enomoto <aenomoto at novell.com> changed:

           What    |Removed                     |Added
          Component|WCF                         |CORLIB
         AssignedTo|aenomoto at novell.com         |mono-bugs at lists.ximian.com

--- Comment #3 from Atsushi Enomoto <aenomoto at novell.com> 2011-02-14 09:51:16 UTC ---
Turned out that it is an issue in BinaryReader's internal buffering.

I have replaced one line in System.IO.BinaryReader.ReadCharBytes() at line 249

//                    int n = m_encoding.GetChars (m_buffer, 0, pos, buffer,
index + chars_read);
int n;
try {
n = m_encoding.GetChars (m_buffer, 0, pos, buffer, index + chars_read);
} catch (ArgumentException ex) {
Console.Error.WriteLine ("m_buffer {0} pos {1} buffer {2} index {3} chars_read
{4} / {5}", m_buffer.Length, pos, buffer.Length, index, chars_read,
Convert.ToBase64String (m_buffer));

.. and I got outputs like:

m_buffer 16 pos 6 buffer 1 index 0 chars_read 0 / ra3xuby/AAAAAAAAAAAAAA==

Every time it fails, the outputs are like this. (Not exactly the same every
time, but similar.)

When I tried to convert this byte array into char array like:

Console.WriteLine (Encoding.UTF8.GetChars (Convert.FromBase64String (b64), 0,
6, new char [1], 0));

which is equivalent to what BinaryReader does, it results in the same
ArgumentException for insufficent char buffer, on both mono *and .NET*:

Unhandled Exception: System.ArgumentException: The output char buffer is too
small to contain the decoded characters, encoding 'Unicode (UTF-8)' fallback
Parameter name: chars
   at System.Text.Encoding.ThrowCharsOverflow(DecoderNLS decoder, Boolean
   at System.Text.UTF8Encoding.GetChars(Byte* bytes, Int32 byteCount, Char*
chars, Int32 charCount, DecoderNLS baseDecoder)
   at System.Text.UTF8Encoding.GetChars(Byte[] bytes, Int32 byteIndex, Int32
byteCount, Char[] chars, Int32 charIndex)

As the error message means, the input byte buffer is likely "invalid" as in
UTF8 sequence, and the conversion results will become larger than char[1].

There *may* be other issues than the BinaryReader buffering, but this should be
resolved first to exactly understand what goes on there.

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