Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-1607

Incorrect serialization of large arrays

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.2.4
    • Affects Version/s: 2.0
    • Component/s: BSON
    • Labels:

      Serialize an array with more than 100k elements:

      using System.IO;
      using MongoDB.Bson.IO;
      
      public class Bug {
      
          public static void Main() {
      
              var stream = File.OpenWrite("foo.bson");
              var writer = new BsonBinaryWriter(stream);
      
              writer.WriteStartDocument();
              writer.WriteName("a");
              writer.WriteStartArray();
              for (int i=0; i<110000; i++)
                  writer.WriteInt32(17);
              writer.WriteEndArray();
              writer.WriteEndDocument();
         }
      }
      

      Dump the resulting bson; all the array elements past the first 100k have "1" as a field name.

      4: a: DOC len=11aeef(1158895) EOO=11aef5 parent=0
      b: 0: int32 11 00 00 00
      12: 1: int32 11 00 00 00
      19: 2: int32 11 00 00 00
      20: 3: int32 11 00 00 00
      27: 4: int32 11 00 00 00
      2e: 5: int32 11 00 00 00
      ...
      109d59: 99996: int32 11 00 00 00
      109d64: 99997: int32 11 00 00 00
      109d6f: 99998: int32 11 00 00 00
      109d7a: 99999: int32 11 00 00 00
      109d85: 1: int32 11 00 00 00
      109d8c: 1: int32 11 00 00 00
      109d93: 1: int32 11 00 00 00
      109d9a: 1: int32 11 00 00 00
      ...
      11aed2: 1: int32 11 00 00 00
      11aed9: 1: int32 11 00 00 00
      11aee0: 1: int32 11 00 00 00
      11aee7: 1: int32 11 00 00 00
      11aeee: 1: int32 11 00 00 00
      11aef5: EOO
      11aef6: EOO
      

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            bruce.lucas@mongodb.com Bruce Lucas (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: