achow101
commented at 8:24 pm on December 11, 2023:
member
CWallet::LoadWallet() expects to be called after a CWallet is constructed, but before any of its member functions called. Doing so invalidates pointers which causes issues with some PRs and branches that I am working on. This was being used incorrectly in a few tests and benchmarks, resulting in segfaults.
As a precaution for this kind of issue in the future, I’ve also added a few asserts to LoadWallet() so that developers will notice when it is used incorrectly.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
Conflicts
Reviewers, this pull request conflicts with the following ones:
#27865 (wallet: Track no-longer-spendable TXOs separately by achow101)
#27286 (wallet: Keep track of the wallet’s own transaction outputs in memory by achow101)
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
DrahtBot renamed this:
tests, bench: Fix issue with CWalelt::LoadWallet() being called in the wrong places
tests, bench: Fix issue with CWalelt::LoadWallet() being called in the wrong places
on Dec 11, 2023
achow101 renamed this:
tests, bench: Fix issue with CWalelt::LoadWallet() being called in the wrong places
tests, bench: Fix issue with CWallet::LoadWallet() being called in the wrong places
on Dec 11, 2023
tests, bench: Remove incorrect LoadWallet() calls
LoadWallet() must only be called immediately after a CWallet is
constructed, or not at all. Doing so after any other CWallet member
functions have been called may cause pointers and other objects
setup by other those functions to become invalidated.
Since these tests and benchmarks are using completely new wallets with
mock databases, it's not necessary to call LoadWallet() anyways, so
these can be dropped.
fb0b6ca4e5
wallet: Assert that the wallet is not initialized in LoadWallet
LoadWallet() cannot be run after the wallet has been initialized. So
assert that to avoid making this mistake in the future.
bd7f5d33e3
achow101 force-pushed
on Dec 11, 2023
DrahtBot added the label
CI failed
on Dec 11, 2023
furszy approved
furszy
commented at 10:45 pm on December 11, 2023:
member
ACKbd7f5d33
For a follow-up, we should make CWallet::LoadWallet() private and replace all those calls for CWallet::Create().
DrahtBot removed the label
CI failed
on Dec 12, 2023
S3RK
commented at 8:18 am on December 12, 2023:
contributor
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: 2024-11-23 09:12 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me