build: run constant-time tests in both test suites #1944

pull Yudis-bit wants to merge 2 commits into bitcoin-core:master from Yudis-bit:cmake-run-constant-time-tests changing 8 files +61 −11
  1. Yudis-bit commented at 10:15 AM on September 27, 2026: contributor

    Both build systems build ctime_tests without running it as part of the standard test suite. This change registers constant-time test execution in both CTest and Autotools make check.

    When MemorySanitizer is enabled, the test executes directly; under Valgrind builds, it runs under valgrind --error-exitcode=42. For Valgrind configurations, registration is cleanly omitted with a configure notice if the binary is absent or during cross-compilation. The Autotools integration employs a dedicated runner to prevent a global LOG_COMPILER from wrapping Valgrind twice, allowing the standalone CI invocation in ci/ci.sh to be retired.

    Verification covers both CMake and Autotools suites under standard, MSan, and Valgrind configurations, confirming that deliberate branching on poisoned secrets triggers test failure while clean trees pass.

    Addresses #1560.

  2. Yudis-bit requested review from Copilot on Sep 27, 2026
  3. Copilot commented at 10:15 AM on September 27, 2026: none

    Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

  4. hebasto commented at 3:22 PM on September 27, 2026: member

    Addresses the CMake part of #1560. Autotools integration remains separate.

    I'd prefer to modify both build systems at the same time.

  5. Yudis-bit renamed this:
    cmake: run constant-time tests with CTest
    build: run constant-time tests in both test suites
    on Sep 27, 2026
  6. Yudis-bit commented at 3:54 PM on September 27, 2026: contributor

    @hebasto Added Autotools support in 93b2cc9. make check now runs the constant-time test under Valgrind, or directly for MSan builds. I also removed the separate CI invocation.

    Both test suites pass. A temporary branch on poisoned secret data makes both fail; they pass again after restoring the source.

  7. fametrano commented at 8:56 PM on October 21, 2026: contributor

    tACK 93b2cc9e45f09e78cc6327a5111e19ee9e7fd6b7. I wanted to see both test suites catch a real constant-time leak. They do, and the clean tree passes.

    On Linux aarch64 (Debian trixie, GCC 14, Valgrind 3.24), I ran the full ctest and make check suites on this branch, then again with a branch on seckey[0] added to secp256k1_ec_seckey_verify. Without the branch, both suites pass. With it, both fail on the ctime test, with two "Conditional jump or move depends on uninitialised value(s)" errors. Under make check, Valgrind runs the real binary in .libs, not the libtool wrapper, and exits with status 42. make check TESTS=ctime_tests.sh LOG_COMPILER=false passes, so a global LOG_COMPILER does not wrap the script. On master with the same branch added, both suites pass, because neither runs ctime_tests. The CMake binary from that build, run by hand under Valgrind, fails. I did not test MSan or cross-compiled builds. I can share the logs.

  8. theStack added the label build on Nov 15, 2026
  9. theStack added the label ci on Nov 15, 2026
  10. cmake: run constant-time tests with CTest 34ba8fbb80
  11. autotools: run constant-time tests in make check
    Run ctime_tests through a shell test with its own runner so LOG_COMPILER
    does not wrap it a second time in CI. Prefer MSan when enabled; otherwise
    use Valgrind with --error-exitcode=42 for native builds when available.
    
    Remove the separate CI invocation now that make check covers it, and
    document how to run or disable the test.
    9a90de4366
  12. Yudis-bit force-pushed on Nov 22, 2026
  13. Yudis-bit commented at 5:43 AM on November 22, 2026: contributor

    Rebased on master (5959bed) after #1996, no logic changes. Re-ran ctest and make check with Valgrind (including a deliberate secret branch to confirm both fail). Range-diff against 93b2cc9:

    1:  00ff182 ! 1:  34ba8fb cmake: run constant-time tests with CTest
        @@ Commit message
         
          ## CMakeLists.txt ##
         @@ CMakeLists.txt: if(SECP256K1_BUILD_CTIME_TESTS)
        -     try_append_c_flags(-fno-sanitize-memory-param-retval)
        +     try_append_c_flags(-fno-sanitize-memory-param-retval TARGET secp256k1_common)
              set(print_msan_notice YES)
            endif()
         -  unset(msan_enabled)
        @@ src/CMakeLists.txt
         @@ src/CMakeLists.txt: endif()
          if(SECP256K1_BUILD_CTIME_TESTS)
            add_executable(ctime_tests ctime_tests.c)
        -   target_link_libraries(ctime_tests secp256k1)
        +   target_link_libraries(ctime_tests secp256k1_common secp256k1_modules secp256k1)
         +
         +  if(msan_enabled)
         +    add_test(NAME secp256k1.ctime_tests COMMAND ctime_tests)
    2:  93b2cc9 = 2:  9a90de4 autotools: run constant-time tests in make check
    

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-12-04 01:15 UTC

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