[SERVER-30424] Coverity analysis defect 101903: Dereference before null check Created: 31/Jul/17  Updated: 30/Oct/23  Resolved: 14/Aug/17

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

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

Issue Links:
Depends
Duplicate
is duplicated by SERVER-29324 Coverity analysis defect 101644: Dere... Closed
Related
related to SERVER-30425 Coverity analysis defect 101902: Dere... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:
Linked BF Score: 0

 Description   

All paths that lead to this null pointer comparison already dereference the pointer earlier

Defect 101903 (STATIC_C)
Checker REVERSE_INULL (subcategory none)
File: /src/mongo/db/db.cpp
Function mongo::<unnamed>::shutdownTask()
/src/mongo/db/db.cpp, line: 1076
Null-checking "opCtx" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.

        if (opCtx) {



 Comments   
Comment by Githook User [ 14/Aug/17 ]

Author:

{'username': 'kaloianm', 'email': 'kaloian.manassiev@mongodb.com', 'name': 'Kaloian Manassiev'}

Message: SERVER-30424 Interrupt user operations after ReplicationCoordinator has been shut down
Branch: master
https://github.com/mongodb/mongo/commit/2dee416aadec3a82063f748c6b36b468df7999af

Comment by Githook User [ 14/Aug/17 ]

Author:

{'name': 'Kaloian Manassiev', 'username': 'kaloianm', 'email': 'kaloian.manassiev@mongodb.com'}

Message: SERVER-30424 Remove opCtx/serviceContext null checks from db.cpp since ServiceContext must always exist
Branch: master
https://github.com/mongodb/mongo/commit/58b36b8bbc6ca7159e100ada6dc15852af0a8661

Comment by Esha Maharishi (Inactive) [ 11/Aug/17 ]

kaloian.manassiev, I think this might be due to your commit to put the chunk loader on the ServiceContext.

A line that was added in that commit unconditionally dereferences the opCtx:

https://github.com/mongodb/mongo/blame/r3.5.11/src/mongo/db/db.cpp#L1010

but later in that function, there is an if(opCtx) check:

https://github.com/mongodb/mongo/blame/r3.5.11/src/mongo/db/db.cpp#L1076

Generated at Thu Feb 08 04:23:46 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.