[GODRIVER-1373] stack overflow when assigning values to a map Created: 24/Oct/19 Updated: 27/Oct/23 Resolved: 25/Oct/19 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | BSON, CRUD |
| Affects Version/s: | 1.1.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Folajimi Sparse | Assignee: | Isabella Siu (Inactive) |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Ubuntu 16.04, Intel Core i5, MongoDB version 4.2 |
||
| Description |
|
Running the following snippet:
gives the following error:
|
| Comments |
| Comment by Isabella Siu (Inactive) [ 25/Oct/19 ] |
|
The stack overflow is caused by a circular map. InsertOne marshals the object it's inserting into bson, so it tries to marshal u1, which tries to marshal u2, which tries to marshal u1, and so on. Trying to marshal this struct with mgo/bson or with the encoding/json library gives the same result. To avoid this circular marshaling, one option is storing user IDs instead of embedded objects in the map. |