Repository navigation
Conversation
l0rinc
force-pushed
the
l0rinc/warn-big-dbcache
branch
from
September 7, 2025 04:33
e2925a0 to
b27b73a
Compare
-dbcache
l0rinc
force-pushed
the
l0rinc/warn-big-dbcache
branch
8 times, most recently
from
September 7, 2025 17:06
f5b2c5b to
cecad5d
Compare
### Summary Oversized allocations can cause out-of-memory errors or heavy swapping, grinding the system to a halt. ### Fix Add a minimal system helper to query total physical RAM on Linux/macOS/Windows (see https://godbolt.org/z/KTTx73Y94). `CalculateCacheSizes()` now emits a startup warning if the configured `-dbcache` exceeds a cap derived from system RAM. If total RAM < 2 GiB, cap is `DEFAULT_KERNEL_CACHE` = `450MiB`, otherwise cap is 75% of total RAM. The threshold is chosen to be close to values commonly used in https://github.com/raspiblitz/raspiblitz/blob/dev/home.admin/_provision.setup.sh#L98-L115: | Total RAM | `dbcache` (MiB) | raspiblitz % | proposed cap (MiB) | |----------:|----------------:|-------------:|-------------------:| | 1 GiB | 512 | 50.0% | 450* | | 2 GiB | 1536 | 75.0% | 1536 | | 4 GiB | 2560 | 62.5% | 3072 | | 8 GiB | 4096 | 50.0% | 6144 | | 16 GiB | 4096 | 25.0% | 12288 | | 32 GiB | 4096 | 12.5% | 24576 | ### Reproducer Starting `bitcoind` on a 64 GiB system with a dbcache of 60GiB with: > ./build/bin/bitcoind -dbcache=60000 warns now as follows: ``` 2025-09-07T04:32:20Z [warning] A 59990 MiB dbcache may be too large for system memory of only 65536 MiB. 2025-09-07T04:32:20Z Cache configuration: 2025-09-07T04:32:20Z * Using 2.0 MiB for block index database 2025-09-07T04:32:20Z * Using 8.0 MiB for chain state database 2025-09-07T04:32:20Z * Using 59990.0 MiB for in-memory UTXO set (plus up to 286.1 MiB of unused mempool space) ``` Co-authored-by: openoms <[email protected]>
l0rinc
force-pushed
the
l0rinc/warn-big-dbcache
branch
from
September 7, 2025 17:11
cecad5d to
52f75c1
Compare
l0rinc
pushed a commit
that referenced
this pull request
Jul 22, 2026
…AFL fork faada35 fuzz: [refactor] Use 100'000 digit separator in __AFL_LOOP (MarcoFalke) fae067e fuzz: Avoid dangling prevoutfetch threads after AFL fork (MarcoFalke) Pull request description: Presumably fixes https://issues.oss-fuzz.com/issues/536943806 This is a bit confusing, because the issue was already fixed in commit f608a40, by removing the AFL forkserver. However, OSS-Fuzz doesn't go through the AFL_LOOP, but through the AFL libFuzzer driver: ``` #0 0x7e055245baab in __pthread_clockjoin_ex /build/glibc-B3wQXB/glibc-2.31/nptl/pthread_join_common.c:89:6 #1 0x5a27e904dcdd in operator() /src/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:293:14 #2 0x5a27e904dcdd in Join<(lambda at /src/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:292:44)> /src/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_thread_arg_retval.h:75:9 #3 0x5a27e904dcdd in ___interceptor_pthread_join /src/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:292:25 #4 0x5a27e90f4044 in std::__1::thread::join() #5 0x5a27e9366277 in ThreadPool::Stop() [bitcoin-core/src/util/threadpool.h:146](https://github.com/bitcoin/bitcoin/blob/7d8137c1417b61589949b3e8b081e5310fe335f3/src/util/threadpool.h#L146):53 #6 0x5a27e9365db9 in ThreadPool::~ThreadPool() [bitcoin-core/src/util/threadpool.h:94](https://github.com/bitcoin/bitcoin/blob/7d8137c1417b61589949b3e8b081e5310fe335f3/src/util/threadpool.h#L94):9 ... #32 0x5a27e95a9506 in (anonymous namespace)::ResetChainman(TestingSetup&) (.12669) [bitcoin-core/src/test/fuzz/process_messages.cpp:44](https://github.com/bitcoin/bitcoin/blob/7d8137c1417b61589949b3e8b081e5310fe335f3/src/test/fuzz/process_messages.cpp#L44):27 #33 0x5a27e95a8c60 in process_messages_fuzz_target(std::__1::span<unsigned char const, 18446744073709551615ul>) [bitcoin-core/src/test/fuzz/process_messages.cpp:141](https://github.com/bitcoin/bitcoin/blob/7d8137c1417b61589949b3e8b081e5310fe335f3/src/test/fuzz/process_messages.cpp#L141):9 ... #36 0x5a27e97b7190 in test_one_input(std::__1::span<unsigned char const, 18446744073709551615ul>) bitcoin-core/src/test/fuzz/fuzz.cpp:86:5 #37 0x5a27e97b7190 in LLVMFuzzerTestOneInput bitcoin-core/src/test/fuzz/fuzz.cpp:214:5 #38 0x5a27e90ada19 in LLVMFuzzerRunDriver /src/aflplusplus/utils/aflpp_driver/aflpp_driver.c:427:13 #39 0x5a27e90ad69b in main /src/aflplusplus/utils/aflpp_driver/aflpp_driver.c:323:10 #40 0x7e055223b082 in __libc_start_main /build/glibc-B3wQXB/glibc-2.31/csu/libc-start.c:308:16 #41 0x5a27e8fc602d in _start ``` So the correct fix would be to set `AFL_DRIVER_DONT_DEFER=1`. Ref: https://github.com/AFLplusplus/AFLplusplus/blob/ad5304010ae3be9d5cdc1ba51b09e14169c5cb87/utils/aflpp_driver/aflpp_driver.c#L161 However, I don't know how to do this on OSS-Fuzz, so just drop the threads for now, because there are dedicated fuzz targets to test the multi-threaded case anyway. ACKs for top commit: l0rinc: ACK faada35 andrewtoth: lgtm ACK faada35 sedited: ACK faada35 Tree-SHA512: c249d7267f789084968f8510531f60fc71c9fbd6b4e574a181fd6da1af19a3cb7c03ba60c3ca70244b56ce44c602293517cdb6b0e969b4a2cc9d1afaa49ab0f8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Oversized allocations can cause out-of-memory errors or heavy swapping, grinding the system to a halt.
Fix
Added a minimal system helper to query total physical RAM on Linux/macOS/Windows.
CalculateCacheSizes()now emits a startup warning if the configured-dbcacheexceeds a cap derived from system RAM.If total RAM < 2 GiB, cap is
DEFAULT_KERNEL_CACHE(450MiB), otherwise it's 75% of total RAM.We're not modifying the set value, just issuing a warning.
Cap
The threshold is chosen to be close to values commonly used in raspiblitz:
dbcache(MiB)Reproducer
Starting
bitcoindon a 64 GiB system with a dbcache of 60GiB with:warns now as follows: