[SERVER-56350] Coverity analysis defect 119880: Uninitialized scalar field in OwnedValueAccessor Created: 26/Apr/21  Updated: 29/Oct/23  Resolved: 09/Jun/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 5.1.0-rc0

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

Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Query Execution 2021-06-14
Participants:

 Description   

In OwnedValueAccessor, _val will be left uninitialized if the default constructor is used. It should probably have a default value of zero, as other classes in this file do so.

/**
 * Accessor for a slot which can own the value held by that slot.
 */
class OwnedValueAccessor final : public SlotAccessor {
public:
    OwnedValueAccessor() = default;
 
// omitted
 
private:
    bool _owned{false};
    TypeTags _tag{TypeTags::Nothing};
    Value _val;  // <--------------
};

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/exec/sbe/values/slot.h:199: UNINIT_CTOR 119880 The compiler-generated constructor for this class does not initialize "_val".



 Comments   
Comment by Vivian Ge (Inactive) [ 06/Oct/21 ]

Updating the fixversion since branching activities occurred yesterday. This ticket will be in rc0 when it’s been triggered. For more active release information, please keep an eye on #server-release. Thank you!

Comment by Githook User [ 09/Jun/21 ]

Author:

{'name': 'Sajed Nahian', 'email': 'sajed.nahian@mongodb.com'}

Message: SERVER-56350 Add default value to OwnedValueAccessor::_val
Branch: master
https://github.com/mongodb/mongo/commit/bf1cbccab6e465e6d3b8facec5f747f539ab7f43

Comment by Kyle Suarez [ 27/Apr/21 ]

Removing this from the epic as it's not required for 5.0, but leaving it in the queue for triage.

Comment by Kyle Suarez [ 26/Apr/21 ]

Like some of the other accessors, _value should default to zero.

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