[CSHARP-278] Document potential stack overflow in BsonValue.Create() and similar methods dealing with collections Created: 23/Jul/11 Updated: 02/Apr/15 Resolved: 12/Apr/12 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | 1.4 |
| Fix Version/s: | 1.4.1 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Roman Kuzmin | Assignee: | Robert Stam |
| Resolution: | Done | Votes: | 0 |
| Labels: | crash | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Backwards Compatibility: | 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>(); 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. |
| Comments |
| Comment by Robert Stam [ 12/Apr/12 ] |
|
The driver now keeps track of the serialization depth (recursion level) and throws a BsonSerializationException when the depth exceeds 100 (configurable). So now it no longer throws a StackOverflowException. |