node: don't abort on invalid -dbcache in settings.json #36347

pull 0xShadowX wants to merge 1 commits into bitcoin:master from 0xShadowX:fix-dbcache-settings-abort changing 3 files +14 −2
  1. 0xShadowX commented at 5:16 PM on September 26, 2026: none

    LogOversizedDbCache (added in #33333) is noexcept, but it reads -dbcache through CalculateDbCacheBytes -> GetIntArg. GetIntArg throws when settings.json has a number that isn't an integer or doesn't fit in int64, e.g. {"dbcache": 4096.5}. The exception hits the noexcept boundary and bitcoind aborts during startup:

    libc++abi: terminating due to uncaught exception of type std::runtime_error: JSON integer out of range
    

    This removes noexcept. The exception now reaches the handler in AppInit, and the node exits with status 1 and an error message instead of aborting:

    EXCEPTION: St13runtime_error
    JSON integer out of range
    bitcoin in AppInit()
    

    The added case in feature_settings.py writes {"dbcache": 4096.5} to settings.json and checks that startup fails with that message from AppInit.

  2. DrahtBot commented at 5:16 PM on September 26, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

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

    Type Reviewers
    ACK 8144225309, Hamza1610

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

  3. in test/functional/feature_settings.py:89 in 75e297d791 outdated
      84 | @@ -85,6 +85,11 @@ def run_test(self):
      85 |              fp.write('{"key": 1, "key": 2}')
      86 |          node.assert_start_raises_init_error(expected_msg='Found duplicate key key in settings file', match=ErrorMatch.PARTIAL_REGEX)
      87 |  
      88 | +        # Test a non-integer dbcache value is reported by AppInit instead of aborting
      89 | +        with settings.open("w") as fp:
    


    Hamza1610 commented at 7:20 PM on October 7, 2026:

    I would suggest that there is test for integer eg. 4096. makes


    0xShadowX commented at 8:49 PM on October 7, 2026:

    Added a test with dbcache: 4096 in 47e3f3633e: the node starts and the value is read from the settings file. I put it before the non-integer case so the later -nosettings checks still see an invalid settings file.

  4. Hamza1610 commented at 7:22 PM on October 7, 2026: none

    Concept ACK

  5. 0xShadowX force-pushed on Oct 7, 2026
  6. Hamza1610 commented at 12:53 PM on October 8, 2026: none

    ACK 47e3f36

  7. sedited requested review from l0rinc on Oct 8, 2026
  8. DrahtBot added the label CI failed on Oct 9, 2026
  9. maflcko commented at 4:44 PM on October 13, 2026: member

    The ci fails. Can this be closed, or are you still working on this?

  10. node: don't abort on invalid -dbcache in settings.json
    LogOversizedDbCache is noexcept, but it reads -dbcache through
    GetIntArg, which throws when settings.json holds a number that is not
    an integer or doesn't fit in int64 (e.g. {"dbcache": 4096.5}). The
    exception hits the noexcept boundary and std::terminate aborts
    bitcoind during startup.
    
    Remove noexcept so the exception reaches AppInit like it does for other
    integer settings, and the node exits with an error message instead of
    aborting.
    2e00693220
  11. 0xShadowX force-pushed on Oct 13, 2026
  12. 0xShadowX commented at 8:32 PM on October 13, 2026: none

    The failure was in the new test, not the fix: {"dbcache": 4096} triggers the oversized-dbcache warning on the 7 GiB macOS runner, and the unexpected stderr fails stop_node. Switched the test values to 300 / 300.5, which stay below the 450 MiB floor of ShouldWarnOversizedDbCache, so the warning can't fire on any machine. Still interested in getting this in.

  13. DrahtBot removed the label CI failed on Oct 20, 2026
  14. DrahtBot requested review from Hamza1610 on Nov 1, 2026
  15. sedited commented at 7:35 PM on November 4, 2026: contributor

    I don't know about this patch. This is a crash that is basically only reachable if the user does something very weird. Imo just crashing seems preferable for these cases?

  16. 0xShadowX commented at 8:01 PM on November 4, 2026: none

    Fair point, a crash on a hand-edited, nonsensical settings.json is arguably the right behaviour. Closing, thanks for taking a look.

  17. 0xShadowX closed this on Nov 4, 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-11-14 18:51 UTC

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