[SERVER-74401] Coverity analysis defect 135206: Division or modulo by float zero Created: 27/Feb/23  Updated: 29/Oct/23  Resolved: 02/Mar/23

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

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

Issue Links:
Depends
Assigned Teams:
Storage Execution
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Execution Team 2023-03-06
Participants:
Linked BF Score: 135

 Description   

Division or modulo by float zero

This could cause an immediate crash or incorrect computation. An expression which may be zero is used as a divisor in floating-point arithmetic.
/src/mongo/db/storage/collection_markers.cpp:466: DIVIDE_BY_ZERO 135206 Checking "numRecords == 0LL" implies that "numRecords" is 0 on the true branch.
/src/mongo/db/storage/collection_markers.cpp:487: DIVIDE_BY_ZERO 135206 In expression "(double)dataSize / (double)numRecords", division by expression "numRecords" which may be zero has undefined behavior.



 Comments   
Comment by Githook User [ 02/Mar/23 ]

Author:

{'name': 'Haley Connelly', 'email': 'haley.connelly@mongodb.com', 'username': 'haleyConnelly'}

Message: SERVER-74401 Disallow divide by 0 in CollectionTruncateMarkers
Branch: master
https://github.com/mongodb/mongo/commit/304e3dad62df7b36d5c815c49eed8bda15c6c6ab

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