[SERVER-61722] Coverity analysis defect 121184: Explicit null dereferenced Created: 24/Nov/21  Updated: 27/Oct/23  Resolved: 11/Jan/22

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

Type: Bug Priority: Major - P3
Reporter: Coverity Collector User Assignee: A. Jesse Jiryu Davis
Resolution: Gone away Votes: 0
Labels: coverity, neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-61143 Import donated collections Closed
Operating System: ALL
Participants:

 Description   

Explicit null dereferenced

A null pointer dereference will occur. Dereference of an explicit null value
/src/mongo/db/storage/wiredtiger/wiredtiger_import.cpp:59: FORWARD_NULL 121184 Dereferencing null pointer "conn".



 Comments   
Comment by Eric Milkie [ 11/Jan/22 ]

The source has changed since this defect was created. When I rewound my local git copy to Nov 24, the source looked like this around line 59:

    // TODO (SERVER-61138): Record collections' metadata.
    conn->close(conn, nullptr);
    // TODO (SERVER-61143): Import collections into main WT instance.

So I think Coverity was sad about dereferencing conn without checking it for null. The code for wiredTigerRollbackToStableAndGetMetadata() is different now and is protected against calling close against a null conn.

Comment by A. Jesse Jiryu Davis [ 11/Jan/22 ]

This is confusing to me. The new code that Coverity dislikes is:

    WT_CURSOR* cursor;
    uassertWTOK(
        session->open_cursor(session,
                             "{}{}"_format(WiredTigerKVEngine::kTableUriPrefix, ident).c_str(),
                             nullptr,
                             nullptr,
                             &cursor));

But there's lots of cases where we pass nullptr for the 3rd and 4th params of open_cursor, e.g. here. What's Coverity complaining about?

Comment by Benety Goh [ 10/Jan/22 ]

The git history suggests that Coverity is flagging new code introduced in SERVER-61143.

Let's send this over to Serverless for a first look. jesse

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