test: add script_tests cases covering interpreter mutants #36054

pull ViniciusCestarii wants to merge 4 commits into bitcoin:master from ViniciusCestarii:kill-interpreter-mutants changing 1 files +7 −0
  1. ViniciusCestarii commented at 7:03 PM on August 21, 2026: contributor

    Kills some live mutants on interpreter.cpp that affect consensus found by https://bitcoincore.space. They are:

    <details> <summary><a href="https://bitcoincore.space/src/script/interpreter.cpp#3951">interpreter.cpp#3951</a>: <code>OP_FROMALTSTACK</code>: removed <code>popstack(altstack)</code></summary>

    diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp
    index 98b16eca6b..68265d20b5 100644
    --- a/src/script/interpreter.cpp
    +++ b/src/script/interpreter.cpp
    @@ -698,7 +698,7 @@ bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript&
                         if (altstack.size() < 1)
                             return set_error(serror, SCRIPT_ERR_INVALID_ALTSTACK_OPERATION);
                         stack.push_back(altstacktop(-1));
    -                    popstack(altstack);
    +
                     }
                     break;
    

    </details>

    <details> <summary><a href="https://bitcoincore.space/src/script/interpreter.cpp#4084">interpreter.cpp#4084</a>: <code>OP_WITHIN</code>: removed one <code>popstack(stack)</code></summary>

    diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp
    index 98b16eca6b..874cf5e1cf 100644
    --- a/src/script/interpreter.cpp
    +++ b/src/script/interpreter.cpp
    @@ -1018,7 +1018,7 @@ bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript&
                         CScriptNum bn2(stacktop(-2), fRequireMinimal);
                         CScriptNum bn3(stacktop(-1), fRequireMinimal);
                         bool fValue = (bn2 <= bn1 && bn1 < bn3);
    -                    popstack(stack);
    +
                         popstack(stack);
                         popstack(stack);
                         stack.push_back(fValue ? vchTrue : vchFalse);
    

    </details>

    <details> <summary><a href="https://bitcoincore.space/src/script/interpreter.cpp#3883">interpreter.cpp#3883</a>: opcode limit: <code>opcode > OP_16</code> → <code>opcode >= OP_16</code></summary>

    diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp
    index 98b16eca6b..e985643606 100644
    --- a/src/script/interpreter.cpp
    +++ b/src/script/interpreter.cpp
    @@ -459,7 +459,7 @@ bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript&
     
                 if (sigversion == SigVersion::BASE || sigversion == SigVersion::WITNESS_V0) {
                     // Note how OP_RESERVED does not count towards the opcode limit.
    -                if (opcode > OP_16 && ++nOpCount > MAX_OPS_PER_SCRIPT) {
    +                if (opcode >= OP_16 && ++nOpCount > MAX_OPS_PER_SCRIPT) {
                         return set_error(serror, SCRIPT_ERR_OP_COUNT);
                     }
                 }
    

    </details>

    <details> <summary><a href="https://bitcoincore.space/src/script/interpreter.cpp#3808">interpreter.cpp#3808</a>: <code>IsValidSignatureEncoding</code>: compound type check returns <code>true</code></summary>

    diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp
    index 98b16eca6b..b613a6ac19 100644
    --- a/src/script/interpreter.cpp
    +++ b/src/script/interpreter.cpp
    @@ -133,7 +133,7 @@ bool static IsValidSignatureEncoding(const std::vector<unsigned char> &sig) {
         if (sig.size() > 73) return false;
     
         // A signature is of type 0x30 (compound).
    -    if (sig[0] != 0x30) return false;
    +    if (sig[0] != 0x30) return true;
     
         // Make sure the length covers the entire signature.
         if (sig[1] != sig.size() - 3) return false;
    

    </details>

    Recommend reviewing per commit.

  2. test: cover OP_FROMALTSTACK must pop the altstack
    https://bitcoincore.space/src/script/interpreter.cpp#3951
    3bb87bc61b
  3. test: cover OP_WITHIN must pop all 3 elements
    https://bitcoincore.space/src/script/interpreter.cpp#4084
    331bf79881
  4. test: cover OP_16 does not count towards the opcode limit
    https://bitcoincore.space/src/script/interpreter.cpp#3883
    86c7fb910d
  5. test: cover DERSIG rejects a non-compound signature type
    https://bitcoincore.space/src/script/interpreter.cpp#3808
    4a12773f26
  6. DrahtBot added the label Tests on Aug 21, 2026
  7. DrahtBot commented at 7:03 PM on August 21, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/36054.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    ACK brunoerg, jeanpablojp, instagibbs

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  8. brunoerg commented at 7:17 PM on August 21, 2026: contributor

    Concept ACK

  9. ViniciusCestarii marked this as ready for review on Aug 21, 2026
  10. brunoerg approved
  11. brunoerg commented at 11:34 AM on August 22, 2026: contributor

    ACK 4a12773f269742d2c655beb1b3f5ffe98e9beadb

    I verified the added tests kill the claimed mutants. Nice one adding these cases to script_tests.json.

  12. jeanpablojp commented at 5:44 PM on August 27, 2026: contributor

    tACK 4a12773f269742d2c655beb1b3f5ffe98e9beadb

    I ran the four mutants without the new cases and the whole unit suite still passes, so they really were live. With the PR applied each one only fails the case its own commit adds.

  13. fanquake commented at 7:20 PM on August 27, 2026: member
  14. instagibbs commented at 11:12 AM on August 28, 2026: member

    ACK 4a12773f269742d2c655beb1b3f5ffe98e9beadb

  15. fanquake merged this on Aug 31, 2026
  16. fanquake closed this on Aug 31, 2026


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-08-31 17:51 UTC

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