[SERVER-66897] Coverity analysis defect 122312: Uninitialized pointer field Created: 31/May/22  Updated: 27/Oct/23  Resolved: 13/Sep/22

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

Type: Bug Priority: Major - P3
Reporter: Coverity Collector User Assignee: Celina Tala
Resolution: Works as Designed Votes: 0
Labels: coverity, neweng, save-for-celina
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File Screen Shot 2022-05-31 at 12.05.08 PM.png    
Operating System: ALL
Sprint: Service Arch 2022-09-05, Service Arch 2022-09-19
Participants:

 Description   

Uninitialized pointer field

The pointer field will point to an arbitrary memory location, any attempt to write may cause corruption. A pointer field is not initialized in the constructor
/src/mongo/util/histogram.h:100: UNINIT_CTOR 122312 Class member declaration for "count".
/src/mongo/util/histogram.h:112: UNINIT_CTOR 122312 Non-static class member "_b.count" is not initialized in this constructor nor in any functions that it calls.
/src/mongo/util/histogram.h:101: UNINIT_CTOR 122312 Class member declaration for "lower".
/src/mongo/util/histogram.h:112: UNINIT_CTOR 122312 Non-static class member "_b.lower" is not initialized in this constructor nor in any functions that it calls.
/src/mongo/util/histogram.h:102: UNINIT_CTOR 122312 Class member declaration for "upper".
/src/mongo/util/histogram.h:112: UNINIT_CTOR 122312 Non-static class member "_b.upper" is not initialized in this constructor nor in any functions that it calls.



 Comments   
Comment by Celina Tala [ 13/Sep/22 ]

From Eric Milke: This Coverity defect is meant to show dangerous coding constructs and not necessarily actual bugs. So it does not check to see if uninitialized memory is read, but just if the constructors leave member variables uninitialized. The defect shouldn't appear again unless the code moves or changes too much for Coverity to keep track of code movement. 

Comment by Kyle Suarez [ 13/Sep/22 ]

Sounds good. celina.tala@mongodb.com and billy.donahue@mongodb.com, close this as "Works as Designed"?

Comment by Celina Tala [ 13/Sep/22 ]

kyle.suarez@mongodb.com following up on Billy wrote earlier, the operator*()  is the only method that accesses _b, so the variable will always be written to before they're read. 

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