[SERVER-62167] Coverity analysis defect 121257: Uninitialized scalar field Created: 17/Dec/21  Updated: 29/Oct/23  Resolved: 13/Jan/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 5.3.0

Type: Bug Priority: Major - P3
Reporter: Coverity Collector User Assignee: Christopher Caplinger
Resolution: Fixed Votes: 0
Labels: coverity, neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File Screen Shot 2021-12-17 at 3.05.53 PM.png    
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Server Serverless 2022-01-24
Participants:

 Description   

Uninitialized scalar field

The field will contain an arbitrary value left over from earlier computations. A scalar field is not initialized by the constructor
/src/mongo/db/repl/tenant_migration_recipient_service.h:581: UNINIT_CTOR 121257 Class member declaration for "_backupCursorId".
/src/mongo/db/repl/tenant_migration_recipient_service.cpp:385: UNINIT_CTOR 121257 Non-static class member "_backupCursorId" is not initialized in this constructor nor in any functions that it calls.



 Comments   
Comment by Githook User [ 12/Jan/22 ]

Author:

{'name': 'Christopher Caplinger', 'email': 'christopher.caplinger@mongodb.com', 'username': 'UnicodeSnowman'}

Message: SERVER-62167: Initialize _donorFilenameBackupCursorId to 0
Branch: master
https://github.com/mongodb/mongo/commit/aa4034f56427fe2d894d12700d8126319ca8a2c3

Comment by Kyle Suarez [ 17/Dec/21 ]

_backupCursorId is declared here without an initializer, and the default constructor does not set a value. CursorId is simply a long long so this field would end up being uninitialized.

I'd recommend explicitly setting this to zero, since it seems we use zero as a sentinel value elsewhere to indicate the backup cursor is killed or unset.

Generated at Thu Feb 08 05:54:21 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.