[SERVER-12237] Off-by-one comparison in checkForInterruptFail fail point Created: 02/Jan/14  Updated: 10/Dec/14  Resolved: 09/Jan/14

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

Type: Bug Priority: Trivial - P5
Reporter: Kamran K. Assignee: J Rassi
Resolution: Won't Fix Votes: 0
Labels: 26qa
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-11695 Add checkForInterruptFail fail point Closed
Operating System: ALL
Participants:

 Description   

This seems extremely minor, but I believe the checkForInterruptFail fail point (introduced in SERVER-11695) can incorrectly fail when chance is set to 0 and the random number also happens to be 0:

https://github.com/mongodb/mongo/blob/419be507ff3ccafd1a5dcda9a40144ed6fb4901e/src/mongo/db/kill_current_op.cpp#L155-L161

double next = static_cast<double>(std::abs(checkForInterruptPRNG.nextInt64()));
double upperBound =
    std::numeric_limits<int64_t>::max() * failPointInfo["chance"].numberDouble();
if (next > upperBound) {
    return false;
}
return true;

I would expect chance: 0 to never reach the return true statement.


Version:
419be507ff3ccafd1a5dcda9a40144ed6fb4901e



 Comments   
Comment by Eric Milkie [ 09/Jan/14 ]

Good point, except that comparisons of double precision floating point values will never be exact, so you can't really expect setting the chance to exactly "0.0D" to guarantee the disablement of the failpoint. There are other mechanisms to achieve that effect.

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