argsman: Fix duplicate option assertion to allow HIDDEN category registration #35549

pull pablomartin4btc wants to merge 1 commits into bitcoin:master from pablomartin4btc:fix/argsman-hidden-category-assertion changing 1 files +3 −0
  1. pablomartin4btc commented at 5:17 PM on June 17, 2026: member

    Follow-up to #35470.

    The assertion added in #35470 to prevent duplicate option registration across categories was too strict, it also fired when an option was registered in OptionsCategory::HIDDEN and then again in a real category (or vice versa).

    That is intentional behavior introduced in #13441: options unavailable in a given binary (e.g. GUI args in bitcoind) are pre-registered as hidden so shared bitcoin.conf files don't fail. In bitcoin-qt, SetupServerArgs registers GUI args as hidden, then SetupUIArgs registers them properly under OptionsCategory::GUI, triggering the assertion and crashing on startup (e.g. bitcoin-qt crashes now that #35470 has been merged into master).

    The fix relaxes the assertion to exclude HIDDEN from the cross-category duplicate check, preserving the original intent of #13441 while still catching unintentional duplicates between real categories.

    <details> <summary>Alternative approach considered</summary>

    An alternative fix would have been to make AddHiddenArgs skip args already registered in any category:

    void ArgsManager::AddHiddenArgs(const std::vector<std::string>& names)
    {
        for (const std::string& name : names) {
            size_t eq_index = name.find('=');
            std::string arg_name = name.substr(0, eq_index == std::string::npos ? name.size() : eq_index);
            LOCK(cs_args);
            bool already_registered = std::ranges::any_of(m_available_args, [&](const auto& arg_map) {
                return arg_map.second.contains(arg_name);
            });
            if (!already_registered) {
                AddArg(name, "", ArgsManager::ALLOW_ANY, OptionsCategory::HIDDEN);
            }
        }
    }
    

    This would fix the crash but obscures the intent — silently skipping registrations in AddHiddenArgs makes it harder to reason about what's registered. The chosen approach of relaxing the assertion specifically for HIDDEN is more explicit about why the duplicate is allowed.

    </details>

  2. argsman: allow duplicate registration between HIDDEN and other categories
    The assertion added in #35470 to prevent duplicate option registration
    across categories was too strict — it also fired when an option was
    registered in OptionsCategory::HIDDEN and then again in a real category
    (or vice versa).
    
    This is intentional behavior introduced in #13441: options unavailable
    in a given binary (e.g. GUI args in bitcoind) are pre-registered as
    hidden so shared bitcoin.conf files don't fail. In bitcoin-qt,
    SetupServerArgs registers GUI args as hidden, then SetupUIArgs registers
    them properly under OptionsCategory::GUI, triggering the assertion and
    crashing on startup.
    
    The fix relaxes the assertion to exclude HIDDEN from the cross-category
    duplicate check, preserving the original intent of #13441 while still
    catching unintentional duplicates between real categories.
    f963f2b675
  3. DrahtBot commented at 5:17 PM on June 17, 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/35549.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK ryanofsky, sedited

    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-->

  4. ryanofsky commented at 6:52 PM on June 17, 2026: contributor

    Code review ACK f963f2b67551d903f4d6ea4d6a0479f24561a390 and confirmed this fixes the problem.

    I think the approach implemented is better than alternate approach mentioned and it is better just not worry about duplicates in the hidden category than require AddHiddenArgs to be called after AddArg.

    I also opened #35551 to try to detect this crash in CI

  5. sedited approved
  6. sedited commented at 7:57 PM on June 17, 2026: contributor

    ACK f963f2b67551d903f4d6ea4d6a0479f24561a390

    Thanks for the fix.

  7. fanquake merged this on Jun 18, 2026
  8. fanquake closed this on Jun 18, 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-06-20 23:51 UTC

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