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

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 1.4.1
    • 1.4
    • None
    • Fully Compatible

    Description

      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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: