Project

General

Profile

Bug #18873

Need to use thread safe random number generation (unless c++11 already provides this)

Added by David Zafman about 7 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Normal
Category:
common
Target version:
-
% Done:

0%

Source:
Community (dev)
Tags:
rand, random
Backport:
Regression:
No
Severity:
3 - minor
Reviewed:
Affected Versions:
ceph-qa-suite:
Pull request ID:
Crash signature (v1):
Crash signature (v2):

Description

We are using rand() throughout the code which man says isn't thread safe. We should determine if rand() with c++11 is thread safe or not. If it isn't use some other variant like rand_r(), boost? or c++11 features.

History

#1 Updated by Jos Collin about 7 years ago

David Zafman wrote:

We are using rand() throughout the code which man says isn't thread safe. We should determine if rand() with c++11 is thread safe or not. If it isn't use some other variant like rand_r(), boost? or c++11 features.

The rand() function is not thread-safe. rand() range is often significantly smaller than you want it to be. The C++ <random> library gives you much more powerful PRNGs.

#2 Updated by Jos Collin about 7 years ago

  • Category set to common
  • Assignee set to Jos Collin
  • Source set to Community (dev)

#3 Updated by Jos Collin about 7 years ago

  • Tags set to rand, random

#4 Updated by Jos Collin almost 7 years ago

  • Assignee changed from Jos Collin to Jesse Williamson

Jesse,

I didn't get time to focus on this. Assigning this to you, as you have a PR that implements random number generation.
https://github.com/ceph/ceph/pull/15341

Thanks,
Jos Collin

#5 Updated by Jesse Williamson almost 7 years ago

Just to make sure the signal isn't lost in the noise, the facility in this PR is an interface to the C++11 standard random number facility that will be used to provide fixes for this bug report, once approved:
https://github.com/ceph/ceph/pull/15341

#6 Updated by Sage Weil almost 3 years ago

  • Status changed from New to Closed

Also available in: Atom PDF