DiscussionsIssue archiveOCCT:Foundation Classes

Archived issue #0025717

Non reentrant (and hence non-thread-safe) math_RealRandom / _IntegerRandom

CommunityOCCT:Foundation Classesclosed11 public notes

Search issues

Description

math_*Random uses a function Random2() declared in math_Recipes.hxx. Random2 uses static array and index into that array.

math_RealRandom is used by BRepClass3d_SClassifier which is used by Shape Healing and reinitializes the static arrays over and over again.

The fix will move the above array into a member field.

Steps to reproduce

N/A

Additional information

_RealRandom and _IntegerRandom are going to be created as instantiation of common template class

Public activity

11 archived notes

Participants are labeled by their role within this record.

01Commenter 2
Branch [archived branch] has been created by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Sat Jan 17 18:10:18 2015 +0400

    0025717: Non reentrant (and hence non-thread-safe) math_RealRandom / _IntegerRandom

02Commenter 2
Class IntegerRandom is never used in OCCT thus I believe it can be safely removed, then there is no need in template and we could keep single class RealRandom to contain all the code. Furthermore, RealRandom is used in single place in OCCT, BRepClass3d_SClassifier, and this place supposedly does not require high-quality random numbers (it is just probing points on faces). Hence we can use simple random generator here, such as class added recently in math package, BullardGenerator. In applications requiring high-quality randoms, it is better to use STL generators provided by <random> in C++11, such as mt19937.
03Commenter 2
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: abv
Date: Sun Jan 18 17:08:40 2015 +0300

    0025717: Non reentrant (and hence non-thread-safe) math_RealRandom / _IntegerRandom
    
    Classes math_IntegerRandom and math_RealRandom, and method Random2 in math_Recipes, removed. Class math_BullardGenerator is used instead
04Commenter 4
I propose alternative patch in branch CR25717_1, where old random generator from math_Recipes is removed and math_BullardGenerator is used instead of it in BRepClass3d_SClassifier. Please review.
05Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
06Commenter 6
Minor corrections has been added.

Reviewed. Please test.
07Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
08Commenter 8
Branch [archived branch] has been rebased on the current master
09Commenter 9
Dear Commenter 1,

Branch CR25717_1 from occt git-repository (and master from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested.
[revision removed]

Number of compiler warnings:
occt component:
   Linux: 18 (18 on master)
   Windows: 0 (0 on master)
products component :
   Linux: 11 (11 on master)
   Windows: 1 (1 on master)

Regressions/Differences:
Not detected

Testing cases:
Not needed

Testing on Linux:
Total MEMORY difference: 369400184 / 370114884
Total CPU difference: 53026.35000000031 / 51750.710000000094

Testing on Windows:
Total MEMORY difference: 275891060 / 275769192
Total CPU difference: 34125.078125 / 38148.296875
10Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]
11Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]