init: -maxmempool overflows int64 on 64-bit and aborts startup with a wrong "must be at least" error #35913

issue Samyra312007 opened this issue on August 6, 2026
  1. Samyra312007 commented at 10:48 AM on August 6, 2026: none

    Is there an existing issue for this?

    • I have searched the existing issues

    Current behaviour

    On 64-bit builds, -maxmempool has no upper bound or overflow check. A value of -maxmempool=9223372036855 makes *mb * 1'000'000 overflow int64_t (signed-overflow UB; wraps negative), the resulting max_size_bytes is negative, and CTxMemPool rejects it as though the user had configured too small a mempool. Start-up aborts with: Error: -maxmempool must be at least 5 MB even though the user supplied ~9.2 EB far above the minimum. The node will not start.

    Expected behaviour

    Values that overflow int64_t (or that are absurdly large) should either be clamped or rejected with a clear "too large" / out-of-range error, mirroring the existing 32-bit guard (-maxmempool is set to %i but can't be over %i MB on 32-bit systems, src/node/mempool_args.cpp:51-52), not silently wrap to negative and be reported as "too small".

    Steps to reproduce

    Build (bitcoind only, skip bitcoin-tx/bench/qt): cmake -B build && cmake --build build -t bitcoind Run with an overflowing value: ./src/bitcoind -regtest -maxmempool=9223372036855 Observed: the process aborts before/at node start with -maxmempool must be at least 5 MB. (9223372036855 was chosen because 9223372036854 * 1'000'000 still fits in int64_t; the next increment crosses INT64_MAX.) Minimal failing unit-test snippet (pattern mirrors the existing MemPoolOptionsForTest in src/test/util/txmempool.cpp:29): #include <node/mempool_args.h> #include <util/translation.h> NodeContext node; node.args->ForceSetArg("-maxmempool", "9223372036855"); CTxMemPool::Options mempool_opts{}; mempool_opts.signals = m_node.validation_signals.get(); auto result{ApplyArgsManOptions(*node.args, GetParams(), mempool_opts)}; // result is Ok (overflow not detected here), so we proceed... bilingual_str err; CTxMemPool mp{mempool_opts, err}; // Flatten() rejects because max_size_bytes < 0 ASSERT_TRUE(err.empty()); // FAILS: err == "-maxmempool must be at least 5 MB"

    Relevant log output

    • src/node/mempool_args.cpp:54 — mempool_opts.max_size_bytes = *mb * 1'000'000; computes in int64_t with no bounds check. Only the is_32bit case (:49-52) rejects large values; the 64-bit branch has no guard at all.
    • src/txmempool.cpp:169-172 — Flatten() treats any negative max_size_bytes (which is how an overflowed value lands) as "configured too small" and produces the misleading error.
    • src/init.cpp:1351-1353 — the resulting mempool_error turns into a fatal ChainstateLoadStatus::FAILURE_FATAL, so the node refuses to start. Root cause: the overflow screen that PR bitcoin#32530 added is 32-bit-only; on 64-bit the multiplication result is never validated, so an overflow is misclassified as a "below minimum" config. Confirmed present on this checkout (HEAD = c4fbd3c721714e…, the code at src/node/mempool_limits.cpp:54 matches).

    How did you obtain Bitcoin Core

    Compiled from source

    What version of Bitcoin Core are you using?

    master@c4fbd3c

    Operating system and version

    Ubuntu 24.04 LTS

    Machine specifications

    No response

  2. maflcko commented at 11:21 AM on August 6, 2026: member

    Pretty sure this is true for ~all of arg parsing: There are no type-aware range checks.

  3. Samyra312007 commented at 11:27 AM on August 6, 2026: none

    So, currently is this issue resolved or not. I think it's resolved.

  4. sedited commented at 11:33 AM on August 6, 2026: contributor

    The current handling also seems fine to me, the user is alerted that something is misconfigured after all. Closing again.

  5. sedited closed this on Aug 6, 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-17 04:51 UTC

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