umontreal-simul / TestU01-2009

This is the 2009 version of TestU01, a software library, implemented in the ANSI C language, and offering a collection of utilities for the empirical statistical testing of uniform random number generators.
Apache License 2.0
64 stars 17 forks source link

Fix msan error in Multinom #18

Closed jlebar closed 2 years ago

jlebar commented 2 years ago

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.