[CSHARP-1607] Incorrect serialization of large arrays Created: 17/Mar/16  Updated: 01/Dec/16  Resolved: 17/Mar/16

Status: Closed
Project: C# Driver
Component/s: BSON
Affects Version/s: 2.0
Fix Version/s: 2.2.4

Type: Bug Priority: Major - P3
Reporter: Bruce Lucas (Inactive) Assignee: Robert Stam
Resolution: Done Votes: 1
Labels: cs, regression
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related

 Description   

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



 Comments   
Comment by Githook User [ 17/Mar/16 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}

Message: CSHARP-1607: Fix indexes for very large arrays.
Branch: v2.2.x
https://github.com/mongodb/mongo-csharp-driver/commit/d7e5a38793daf3fdfde959b28b7f56768f98cec2

Comment by Githook User [ 17/Mar/16 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}

Message: CSHARP-1607: Fix indexes for very large arrays.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/ae3e69939f6e41a5033141aa066ef2f012c14457

Generated at Wed Feb 07 21:40:07 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.