[SERVER-61243] Coverity analysis defect 121082: Division or modulo by zero Created: 04/Nov/21  Updated: 29/Oct/23  Resolved: 15/Nov/21

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

Type: Bug Priority: Major - P3
Reporter: Coverity Collector User Assignee: Joshua Lapacik (Inactive)
Resolution: Fixed Votes: 0
Labels: coverity
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File Screen Shot 2021-11-04 at 10.14.18 AM.png    
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: QE 2021-11-15, QE 2021-11-29
Participants:

 Description   

Division or modulo by zero

The program will have undefined behavior, likely a crash. Division or modulo by zero results in undefined behavior.
/src/mongo/db/query/plan_cache.h:283: DIVIDE_BY_ZERO 121082 Checking "numPartitions > 0UL" implies that "numPartitions" and "this->_numPartitions" may be up to 0 on the false branch.
/src/mongo/db/query/plan_cache.h:284: DIVIDE_BY_ZERO 121082 In expression "cacheSize / numPartitions", division by expression "numPartitions" which may be zero has undefined behavior.



 Comments   
Comment by Githook User [ 11/Nov/21 ]

Author:

{'name': 'joshua', 'email': '80741223+jlap199@users.noreply.github.com', 'username': 'jlap199'}

Message: SERVER-61243 Fix PlanCacheBase coverity failure
Branch: master
https://github.com/mongodb/mongo/commit/55f28adb9a2ecb6c4c4078e0adf78590864095c6

Comment by Kyle Suarez [ 04/Nov/21 ]

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