Skip to content

wallet: Fix segfault in CreateWalletFromFile#16796

Merged
meshcollider merged 3 commits intobitcoin:masterfrom
maflcko:1909-walletSegfault
Sep 9, 2019
Merged

wallet: Fix segfault in CreateWalletFromFile#16796
meshcollider merged 3 commits intobitcoin:masterfrom
maflcko:1909-walletSegfault

Conversation

@maflcko
Copy link
Member

@maflcko maflcko commented Sep 3, 2019

Comes with a test to aid review. The test should fail without the fix to bitcoind

The following CreateWalletFromFile issues are fixed:

  • walletFile refers to freed memory and will thus corrupt the debug.log and/or crash the node if read
  • WalletParameterInteraction was moved to CreateWalletFromFile and WalletInit::ParameterInteraction without updating the documentation

@promag
Copy link
Contributor

promag commented Sep 6, 2019

ACK fa73460.

fab3c34 is a nice addition.

@darosior
Copy link
Member

darosior commented Sep 8, 2019

ACK fa73460
Tested locally.

parser.add_argument(
'--data_wallets_dir',
default=os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data/wallets/'),
help='Test data with wallet directories (default: %(default)s)',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% fluent in python and haven't tested this but don't you need to use e.g. % locals() at the end to fill the %(default)s?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done by the argparse module. It can be tested with

$ ./test/functional/wallet_multiwallet.py --help|tail -4
  --data_wallets_dir DATA_WALLETS_DIR
                        Test data with wallet directories (default: /home/marc
                        o/workspace/btc_bitcoin_core/test/functional/data/wall
                        ets/)

Copy link
Contributor

@meshcollider meshcollider left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, code-read ACK fa73460

@meshcollider meshcollider merged commit fa73460 into bitcoin:master Sep 9, 2019
Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test/functional/data/wallets/high_minversion/wallet.dat

I think if we're going to add binary test blobs like this, they should be accompanied with comments saying how they are generated and intended to be maintained. For example, this information could go in accompanying README.md or generate.sh files.

Without this information, as code is updated in the future, and especially if more binary blobs are added, we're going to be faced with unpleasant choices of:

  1. Deleting tests and potentially losing important test coverage when changes are made.
  2. Or having to add ugly workarounds to production or test code to maintain compatibility with test blobs.
  3. Or having to do historical research and archaeology to figure out how to update test blobs.

Better to just record upfront what's in the blobs and how they should be treated. Would be nice to have a followup PR adding this.

@maflcko maflcko deleted the 1909-walletSegfault branch September 10, 2019 12:13
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Sep 10, 2019
fa73460 wallet: Fix segmentation fault in CreateWalletFromFile (MarcoFalke)
fab3c34 test: Print both messages on failure in assert_raises_message (MarcoFalke)
faa1353 wallet: Fix documentation around WalletParameterInteraction (MarcoFalke)

Pull request description:

  Comes with a test to aid review. The test should fail without the fix to bitcoind

  The following `CreateWalletFromFile` issues are fixed:

  * `walletFile` refers to freed memory and will thus corrupt the debug.log and/or crash the node if read
  * `WalletParameterInteraction` was moved to `CreateWalletFromFile` and `WalletInit::ParameterInteraction` without updating the documentation

ACKs for top commit:
  promag:
    ACK fa73460.
  darosior:
    ACK fa73460
  meshcollider:
    LGTM, code-read ACK fa73460

Tree-SHA512: 2aceb63a3f25b90a840cfa08d37f5874aad4eb3df8c2ebf94e2ed18b55809b185e6920bdb345b988bff1fcea5e68a214fe06c361f7da2c01a3cc29e0cc421cb4
maflcko pushed a commit to maflcko/bitcoin-core that referenced this pull request Sep 16, 2019
…high_minversion

2222c96 test: Add notes on how to generate data/wallets/high_minversion (MarcoFalke)

Pull request description:

  I forgot to do this in bitcoin#16796

ACKs for top commit:
  ryanofsky:
    ACK 2222c96

Tree-SHA512: 5f24ffa641b97eac4febad42ade7228b14fa72335c918a10880c5dec86a3ecc3075a31526f275188e07fea95b8e2c6320c64f716099f604b00e13d5366fcee37
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Sep 16, 2019
…high_minversion

2222c96 test: Add notes on how to generate data/wallets/high_minversion (MarcoFalke)

Pull request description:

  I forgot to do this in bitcoin#16796

ACKs for top commit:
  ryanofsky:
    ACK 2222c96

Tree-SHA512: 5f24ffa641b97eac4febad42ade7228b14fa72335c918a10880c5dec86a3ecc3075a31526f275188e07fea95b8e2c6320c64f716099f604b00e13d5366fcee37
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jul 28, 2020
Summary:
wallet: Fix segmentation fault in CreateWalletFromFile (MarcoFalke)
test: Print both messages on failure in assert_raises_message (MarcoFalke)
wallet: Fix documentation around WalletParameterInteraction (MarcoFalke)

Pull request description:

  Comes with a test to aid review. The test should fail without the fix to bitcoind

  The following `CreateWalletFromFile` issues are fixed:

  * `walletFile` refers to freed memory and will thus corrupt the debug.log and/or crash the node if read
  * `WalletParameterInteraction` was moved to `CreateWalletFromFile` and `WalletInit::ParameterInteraction` without updating the documentation

https://github.com/bitcoin/bitcoin/pull/16796/files

---

Backport of Core [[bitcoin/bitcoin#16796 | PR16796]]

Test Plan:
  ninja check check-functional

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D7053
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jul 1, 2021
…high_minversion

2222c96 test: Add notes on how to generate data/wallets/high_minversion (MarcoFalke)

Pull request description:

  I forgot to do this in bitcoin#16796

ACKs for top commit:
  ryanofsky:
    ACK 2222c96

Tree-SHA512: 5f24ffa641b97eac4febad42ade7228b14fa72335c918a10880c5dec86a3ecc3075a31526f275188e07fea95b8e2c6320c64f716099f604b00e13d5366fcee37
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Sep 11, 2021
…high_minversion

2222c96 test: Add notes on how to generate data/wallets/high_minversion (MarcoFalke)

Pull request description:

  I forgot to do this in bitcoin#16796

ACKs for top commit:
  ryanofsky:
    ACK 2222c96

Tree-SHA512: 5f24ffa641b97eac4febad42ade7228b14fa72335c918a10880c5dec86a3ecc3075a31526f275188e07fea95b8e2c6320c64f716099f604b00e13d5366fcee37
kwvg added a commit to kwvg/dash that referenced this pull request Dec 12, 2021
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants