[tor-dev] prob_distr.c: LogLogistic fails stochastic tests on 32-bits mingw

George Kadianakis desnacked at riseup.net
Wed Dec 12 15:47:05 UTC 2018


George Kadianakis <desnacked at riseup.net> writes:

> Hello Riastradh,
>
> as discussed on IRC, Appveyor recently started failing the stochastic
> tests of LogLogistic on 32-bit builds:
>      https://github.com/torproject/tor/pull/576
>      https://ci.appveyor.com/project/torproject/tor/builds/20897462
>
> I managed to reproduce the breakage by cross-compiling Tor and running
> the tests with wine, using this script of ahf: https://github.com/ahf/tor-win32/
>
> Here are my findings:
>
> The following two test cases are breaking 100% reproducibly:
>
>     ok = test_stochastic_log_logistic_impl(M_E, 1e-1);
>     ok = test_stochastic_log_logistic_impl(exp(-10), 1e-2);
>

Aaaaand here are some updates:

I followed your suggestion and turned the tests into deterministic by
sampling from a deterministic randomness source. I verified that all the
crypto_rand() call outputs are now the same between the 32-bit mingw
build and the 64-bit gcc one:
      https://github.com/asn-d6/tor/commit/3d8c86c2f08ad2cc7ed030bbf8e11b110351f5c8

I then focused on the test_stochastic_log_logistic_impl(M_E, 1e-1) test
case and tried to figure out where the deviation was happening between
64-bit gcc and 32-bit mingw... That took a while but I finally got some
figures. Check out my commit that adds some printfs as well:
      https://github.com/asn-d6/tor/commit/36999c640fe824ab9fb85b5d2cd15017a97a532f

So using the output from that that commit I noticed that many times
log_logistic_sample() would give different outputs in these two
systems. In particular sometimes the x value would differ even with the
same (s, p0) pair, and other times the x value would be the same but the
final alpha*pow(x,1/beta) value would differ. Even tho this is the case,
the test would only fail for certain values for beta (as mentioned in my
previous email).

I now inline various such failure cases and one correct one:

Case #1 (same x, different sample value):

     mingw-32:
        beta: 0x1.999999999999ap-4
        s: 3122729323, p0: 0x1.68d18a44b82fbp-1
        x: 0x1.d686a1e7fa35p+0
        alpha*pow(x, 1/beta): 0x1.2affd5bfff433p+10

     gcc-64:
        beta: 0x1.999999999999ap-4        
        s: 3122729323, p0: 0x1.68d18a44b82fbp-1
        x: 0x1.d686a1e7fa35p+0
        alpha*pow(x, 1/beta): 0x1.2affd5bfff434p+10        

Case #2 (same x, different sample value):

     mingw-32:
        beta: 0x1.999999999999ap-4
        s: 738208646, p0: 0x1.a1ecd53def5d3p-2
        x: 0x1.068987864c2aep-2
        alpha*pow(x, 1/beta): 0x1.bfba380255bb8p-19
        
     linux:
        beta: 0x1.999999999999ap-4
        s: 738208646, p0: 0x1.a1ecd53def5d3p-2
        x: 0x1.068987864c2aep-2
        alpha*pow(x, 1/beta): 0x1.bfba380255bb9p-19
         
Case #3 (different x, different sample value):

     mingw-32:
        beta: 0x1.999999999999ap-4
        s: 95364755, p0: 0x1.575b5ea720e3cp-1
        x: 0x1.fb7949976ab04p+0
        alpha*pow(x, 1/beta): 0x1.3e605e169e8cbp+11

     gcc-64:
        beta: 0x1.999999999999ap-4
        s: 95364755, p0: 0x1.575b5ea720e3cp-1
        x: 0x1.fb7949976ab03p+0
        alpha*pow(x, 1/beta): 0x1.3e605e169e8c5p+11

Case #4 (different x, different sample value):

     mingw-32:
        beta: 0x1.999999999999ap-4
        s: 2082443965, p0: 0x1.530a8759113bp-2
        x: 0x1.42989e50ac641p+2
        alpha*pow(x, 1/beta): 0x1.b724d48bf0f6cp+24

     gcc-64:
        beta: 0x1.999999999999ap-4
        s: 2082443965, p0: 0x1.530a8759113bp-2
        x: 0x1.42989e50ac64p+2
        alpha*pow(x, 1/beta): 0x1.b724d48bf0f5ep+24

Case #5 (different x, different sample value):

     mingw-32:
        beta: 0x1.999999999999ap-4
        s: 443038967, p0: 0x1.b0124b971bbf3p-4
        x: 0x1.1f5b72f5f6a3ep+4
        alpha*pow(x, 1/beta): 0x1.143a16cdae94fp+43
        
     gcc-64:
        beta: 0x1.999999999999ap-4
        s: 443038967, p0: 0x1.b0124b971bbf3p-4
        x: 0x1.1f5b72f5f6a3fp+4
        alpha*pow(x, 1/beta): 0x1.143a16cdae958p+43

Case #6 (same sample value):

     mingw-32:
        beta: 0x1.999999999999ap-4
        s: 2932701594, p0: 0x1.b407f600e6d87p-1
        x: 0x1.7bb183ccc47efp-1
        alpha*pow(x, 1/beta): 0x1.181016f03c09p-3

     gcc-64:
        beta: 0x1.999999999999ap-4
        s: 2932701594, p0: 0x1.b407f600e6d87p-1
        x: 0x1.7bb183ccc47efp-1
        alpha*pow(x, 1/beta): 0x1.181016f03c09p-3


More information about the tor-dev mailing list