[SERVER-35841] PseudoRandom should check for invalid function parameters Created: 27/Jun/18  Updated: 09/Jul/18  Resolved: 09/Jul/18

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

Type: Improvement Priority: Major - P3
Reporter: Dianna Hohensee (Inactive) Assignee: DO NOT USE - Backlog - Platform Team
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

These PseudoRandom functions are unsafe for parameter values of 0. It would be nice if they simply error'ed or assert'ed in some easy to diagnose manner.



 Comments   
Comment by Gregory McKeon (Inactive) [ 09/Jul/18 ]

We have an epic for overhauling how we handle randoms, but we won't be adding friendlier checking here now.

Comment by Dianna Hohensee (Inactive) [ 29/Jun/18 ]

Mathias suggested making the functions do this

return std::uniform_int_distribution<T>(0,max)(urbg());

Comment by Ian Whalen (Inactive) [ 29/Jun/18 ]

Assigning to Platforms as pseudorandom we believe is owned by them.

Comment by Eric Milkie [ 27/Jun/18 ]

I feel like it is a programming error to pass 0 to those functions, and if it ever does happen the program will definitively crash anyway, so there's no point in adding friendlier checking here; it will just reduce performance.

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