Skip to content

Commit cbf41ee

Browse files
authored
Fix msan error in Multinom
With a new version of llvm+clang, msan becomes more clever and catches the following use-of-uninitialized-memory error. ``` ==793==WARNING: MemorySanitizer: use-of-uninitialized-value #0 0x7fee2bf29ed7 in Multinom third_party/testu01/testu01_1_2_3/testu01/smultin.c:2203:7 #1 0x7fee2bf25d6e in smultin_Multinomial third_party/testu01/testu01_1_2_3/testu01/smultin.c:2313:4 #2 0x7fee2bf0f022 in sknuth_Permutation third_party/testu01/testu01_1_2_3/testu01/sknuth.c:639:7 ``` We're invoking this as ``` sres_Chi2* res = sres_CreateChi2(); sknuth_Permutation(&gen_, res, p.N, p.n, p.r, p.t); ``` with `N=1`, `n=50'000'000`, `r=0`, and `t=10`.
1 parent 7519ac6 commit cbf41ee

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

testu01/smultin.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2109,7 +2109,7 @@ static void Multinom (unif01_Gen * gen, smultin_Param * par,
21092109
double UnSurHache;
21102110
double HacheLR; /* Dimension of hashing table */
21112111
long i;
2112-
long CoMax; /* Maximum number of balls in any cell */
2112+
long CoMax = -1; /* Maximum number of balls in any cell */
21132113
double X0, X; /* Statistics */
21142114
DeltaIndex j; /* Which power divergence case */
21152115
double SumX2[smultin_MAX_DELTA];

0 commit comments

Comments
 (0)