Test with count == 0 and optimization disabled trip a verify #528

issue deadalnix opened this issue on April 10, 2018
  1. deadalnix commented at 3:00 PM on April 10, 2018: none

    The repro process is a bit involved, but it seems like there is a possible problem somewhere in the ecmult_multi logic (or in gcc itself).

    Repro: Edit ./configure.ac to remove CFLAGS="$CFLAGS -O3" Then:

    $ CFLAGS='-g -O0' ../configure --with-asm=no
    $ make tests && ./tests 0
    [compiling...]
    test count = 0
    random seed = 6a777122d5fd053929192734d4913476
    ../src/field_5x52_impl.h:421: test condition failed: b->magnitude <= 8
    Aborted
    

    It's unclear why this problem doesn't show up when the optimization are turned on. The compiler used is gcc 7.3.0 .

  2. apoelstra commented at 3:53 PM on April 10, 2018: contributor

    Neat! I can confirm that something funny happens in valgrind with ./tests 0. To be honest I had no idea this command was permissible -- my base case has always been ./tests 1.

    I'll look into it. Solution may just be to require count ≥ 1.

  3. deadalnix commented at 5:30 PM on April 10, 2018: none

    I ended up having failures because of some test system that would run with zero because of some bug in the testing system.

    My concern here isn't really that 0 is a very useful thing to test for, but that it put the system is some weird state that reveal a bug either in libsecp256k1 or possibly in gcc's optimizer. I'm not really up to speed with the ecmult_multi part of the code, so I'm unable to really help drill down further at this time.

  4. apoelstra commented at 6:49 PM on April 10, 2018: contributor

    No, it is purely that this line of code https://github.com/bitcoin-core/secp256k1/blob/master/src/tests.c#L2714 in the test jig is not run in the count==0 case, so a couple scalars are uninitialized, so the tests fail randomly. It has nothing to do with the library or with gcc.

  5. apoelstra cross-referenced this on Apr 10, 2018 from issue fix tests.c in the count == 0 case by apoelstra
  6. deadalnix commented at 8:47 PM on April 10, 2018: none

    I see. Thanks for getting to the bottom of this.

  7. sipa closed this on May 31, 2018

  8. sipa referenced this in commit 1e6f1f5ad5 on May 31, 2018
  9. apoelstra cross-referenced this on Nov 23, 2020 from issue make test count iteration configurable by environment variable by apoelstra

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-21 08:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me