Block storage: Fix OOM crash when block is larger than block file size
Summary
When a received block exceeded the MAX_BLOCKFILE_SIZE
limit, the code in FindBlockPos
would just loop forever, adding another element to vinfoBlockFile
each time, eventually causing an allocation failure or the OOM killer killing the process.
The problem is fixed by checking the current CBlockFileInfo
's nSize
for zero. This makes the code behave the same as before if the block does not exceed MAX_BLOCKFILE_SIZE
, if it does exceed it, a file larger than the maximum is created.
Test plan
- ninja check
- sync scalenet past block height 16809, it should not crash
closes #191 (closed)
Edited by Axel Gembe