[SERVER-73889] Coverity analysis defect 135067: Using a moved object Created: 10/Feb/23  Updated: 21/Feb/23  Resolved: 21/Feb/23

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: George Wangensteen
Resolution: Duplicate Votes: 0
Labels: coverity
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File Screenshot 2023-02-10 at 12.17.06 PM.png    
Issue Links:
Duplicate
duplicates SERVER-74238 IDL Compiler Can Generate Use-After-M... Closed
Related
is related to SERVER-74000 clang-tidy should parse generated cpp... Backlog
Assigned Teams:
Service Arch
Operating System: ALL
Sprint: Service Arch 2023-02-20, Service Arch 2023-03-06
Participants:

 Description   

Using a moved object

Using a moved object may lead to an unexpected/undefined behavior. An object is used after it's moved.
/build/7a67446c/mongo/db/modules/enterprise/src/search/text_search_index_commands_gen.cpp:1102: USE_AFTER_MOVE 135067 "nss" is moved (indicated by "std::move(nss)").
/build/7a67446c/mongo/db/modules/enterprise/src/search/text_search_index_commands_gen.cpp:1102: USE_AFTER_MOVE 135067 "nss" is used after it has been already moved.



 Comments   
Comment by George Wangensteen [ 21/Feb/23 ]

This is a somewhat unusual coverity ticket - we can't fix the issue coverity is complaining about directly, because it is in code generated by the IDL compiler. We need to instead fix the IDL compiler to stop generating this sort of code; I filed a ticket that documents the root-cause defect in the IDL compiler that we need to fix and has more context on the root-issue, and am closing this ticket as a duplicate of that one as a result. 

Comment by Kyle Suarez [ 10/Feb/23 ]

While SERVER-73273 is the change that triggered this, it is the fault of the IDL C++ generator, since that does seem to have generated constructors that use the object after the move. Sending this to Service Arch to please take a look.

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