[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: File main.go    

 Description   

main.go

 

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: GODRIVER-1488 turn off DecodeDeepZeroInline for mgocompat.Registry (#312)
Branch: release/1.3
https://github.com/mongodb/mongo-go-driver/commit/4daf0f2ebe5787b97d73ae49d42d723605b53969

Comment by Githook User [ 27/Feb/20 ]

Author:

{'username': 'iwysiu', 'name': 'iwysiu', 'email': 'isabella.siu@10gen.com'}

Message: GODRIVER-1488 turn off DecodeDeepZeroInline for mgocompat.Registry (#312)
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/026d01fa5aaf56799a8ae2c6ec2da402292e0996

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.

Generated at Thu Feb 08 08:36:30 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.