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

Document potential stack overflow in BsonValue.Create() and similar methods dealing with collections

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.4.1
    • Affects Version/s: 1.4
    • Component/s: None
    • Labels:
    • Fully Compatible

      Here is the code that never ends (crashes at some point) because of a cyclic reference:

      var list = new System.Collections.Generic.List<object>();
      list.Add(list);
      var bson = MongoDB.Bson.BsonValue.Create(list);

      Is this a known issue?

      This is not a practical use case, indeed. Collections with recursion are more likely created by mistake, at least in our database related context.

      I do not think this should be fixed. But I propose to document this issue. Users should be informed and aware of this. The example above is silly, cyclic references may be much more subtle in practice.

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            nightroman Roman Kuzmin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: