Skip to content

Commit d17bbc3

Browse files
author
MacroFake
committed
Merge bitcoin/bitcoin#25060: blockstorage: add LIFETIMEBOUND to GetFirstStoredBlock()::start_time
4cb9d21 blockstorage: add LIFETIMEBOUND to GetFirstStoredBlock()::start_time (Jon Atack) Pull request description: Suggested in bitcoin/bitcoin#25016 (comment), the lifetimebound attribute here indicates that a resource owned by the `start_block` param of `CBlockIndex* BlockManager::GetFirstStoredBlock()` can be retained by the method's return value, which enables detecting the use of out-of-scope stack memory (ASan `stack-use-after-scope`) at compile time. See https://releases.llvm.org/12.0.0/tools/clang/docs/AttributeReference.html#lifetimebound and #22278 for related discussion, and #25040 for a similar example. ACKs for top commit: MarcoFalke: review ACK 4cb9d21 Tree-SHA512: a3f5ef83ebb6f08555d7c89f2437a682071b4ad77a7aa3326b6d2282c909bf9fcf4dac6bf05ee1d9931f2102cad4a02df5468bde1cf377d7126e84e8541604dc
2 parents c290249 + 4cb9d21 commit d17bbc3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/node/blockstorage.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
#ifndef BITCOIN_NODE_BLOCKSTORAGE_H
66
#define BITCOIN_NODE_BLOCKSTORAGE_H
77

8+
#include <attributes.h>
89
#include <chain.h>
910
#include <fs.h>
10-
#include <protocol.h> // For CMessageHeader::MessageStartChars
11+
#include <protocol.h>
1112
#include <sync.h>
1213
#include <txdb.h>
1314

@@ -179,7 +180,7 @@ class BlockManager
179180
const CBlockIndex* GetLastCheckpoint(const CCheckpointData& data) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
180181

181182
//! Find the first block that is not pruned
182-
const CBlockIndex* GetFirstStoredBlock(const CBlockIndex& start_block) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
183+
const CBlockIndex* GetFirstStoredBlock(const CBlockIndex& start_block LIFETIMEBOUND) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
183184

184185
/** True if any block files have ever been pruned. */
185186
bool m_have_pruned = false;

0 commit comments

Comments
 (0)