[SERVER-49770] Coverity analysis defect 115958: Copy without assign (Head) Created: 21/Jul/20  Updated: 29/Oct/23  Resolved: 23/Jul/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: Henrik Edin
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: Execution Team 2021-06-14, Execution Team 2021-07-12, Execution Team 2021-07-26, Execution Team 2021-08-09
Participants:

 Description   

Copy without assign

This class has a user-defined copy constructor but no user-defined assignment operator. If the copy constructor is necessary to manage owned resources then a corresponding assignment operator is usually required. If an object of this type is assigned memory leaks and/or use-after-free errors may occur. Note that a compiler-generated assignment operator will perform only a bit-wise copy for any fields that do not have their own assignment operators defined. Class has user-written copy constructor but no user-written assignment operator
/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_radix_store.h:78: COPY_WITHOUT_ASSIGN 115958 Class "mongo::ephemeral_for_test::RadixStore<std::_cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::Head" has a user-written copy constructor "mongo::ephemeral_for_test::RadixStore<std::cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::Head::Head(mongo::ephemeral_for_test::RadixStore<std::cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::_cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::Head const &)" but no corresponding user-written assignment operator.
/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_radix_store.h:950: COPY_WITHOUT_ASSIGN 115958 User-written copy constructor.



 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 [ 22/Jul/21 ]

Author:

{'name': 'Henrik Edin', 'email': 'henrik.edin@mongodb.com', 'username': 'henrikedin'}

Message: SERVER-49770 SERVER-49773 Explicitly delete copy and move assignment operator for ephemeral for test radix Node and Head classes.

Not worth to add at this point as the code does not need them.
Branch: master
https://github.com/mongodb/mongo/commit/fda1dfa7f00600df025b19248605715a6cd47cd8

Comment by Henrik Edin [ 21/Jul/20 ]

We should add a copy assignment operator to the Head class as there is a user defined copy constructor.

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