[GODRIVER-1488] Decode struct infinite recursion with mgocompat Registry Created: 12/Feb/20 Updated: 28/Oct/23 Resolved: 27/Feb/20 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | BSON, mgobson |
| Affects Version/s: | 1.3.0 |
| Fix Version/s: | 1.3.1 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | James Kingston | Assignee: | Isabella Siu (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Description |
|
The attached program triggers the issue. It would seem to be a missing nil check somewhere in this call: if sc.DecodeDeepZeroInline && sd.inline { val.Set(deepZero(val.Type())) }at go.mongodb.org/mongo-driver@v1.3.0/bson/bsoncodec/struct_codec.go:198 Removing the draft field bypasses the issue. Replacing the embedded Common struct with the ID field also bypasses the issue, so there is something in the intersection of those two fields. |
| Comments |
| Comment by Githook User [ 27/Feb/20 ] |
|
Author: {'username': 'iwysiu', 'name': 'iwysiu', 'email': 'isabella.siu@10gen.com'}Message: |
| Comment by Githook User [ 27/Feb/20 ] |
|
Author: {'username': 'iwysiu', 'name': 'iwysiu', 'email': 'isabella.siu@10gen.com'}Message: |
| Comment by Isabella Siu (Inactive) [ 21/Feb/20 ] |
|
Hi jkingston@istreamplanet.com, We investigated this, and found that it was introduced by a change on globalsign/mgo's dev branch that was meant to support inline struct pointers. That change made it so that if a struct contained an inline field, it would zero initialize structs for all of its struct pointers, which introduces this bug. We are going to change mgoRegistry to use our BSON library's inline struct pointer logic, which only zero initializes structs for inline struct pointers when the struct is used. While this is a behavior change, we feel that it is more intuitive for users. |