Skip to content

Conversation

@promag
Copy link
Contributor

@promag promag commented May 29, 2019

Make console line edit disable by default, and only enable once RPCConsole::setClientModel is called.

Fixes #16119.

@fanquake fanquake added the GUI label May 29, 2019
@promag
Copy link
Contributor Author

promag commented May 29, 2019

It's not possible to run RPC commands (not even by bitcoin-cli) if the initial rescan hasn't completed. A long term alternative is to move this rescan after the initialization? /cc @ryanofsky

@ryanofsky
Copy link
Contributor

ryanofsky commented May 30, 2019

A long term alternative is to move this rescan after the initialization? /cc @ryanofsky

Since the rescan loop doesn't hold onto cs_main anymore, I'd expect that RPC commands could work during a rescan, and don't understand exactly what problem causes this crash, and what problem causes bitcoin-cli not to work right now.

Longer term, I think the main thing that needs to happen is for the rescan loop to move out of the wallet into the node (src/node/rescan.cpp or someplace like that) so when multiple wallets are loaded they are all rescanned in parallel instead of sequentially one after another other. I expect the way that would work is that during loading, each wallet would asynchronously request a rescan from the node, passing it a locator. Then after all the wallets are loaded, the node would do a single rescan from the earliest point, sending wallets the normal notifications.

In terms of implementation I would build this on top of #15719 by adding a CBlockLocator argument to Chain::requestNotifications() Chain::handleNotifications(). There would also need to be explicit requestRescan/abortRescan Chain methods to trigger rescans after wallets are loaded, for when users import keys or explicity request rescans.

@promag
Copy link
Contributor Author

promag commented May 30, 2019

and what problem causes bitcoin-cli not to work right now.

Because the server gives RPC_IN_WARMUP:

src/bitcoin-cli -regtest help
error code: -28
error message:
Rescanning...

don't understand exactly what problem causes this crash

Because autoCompleter is null here:
https://github.com/bitcoin/bitcoin/blob/727143b65cdb801a0b755cb8b3aff97da5fe8f27/src/qt/rpcconsole.cpp#L535

I think the main thing that needs to happen is for the rescan loop to move out of the wallet into the node

This would go away right?

/** Add wallets that should be opened to list of init interfaces. */
virtual void Construct(InitInterfaces& interfaces) const = 0;

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.

utACK 727143b65cdb801a0b755cb8b3aff97da5fe8f27

Thanks for the explanations.

This would go away right?

I think adding a CBlockLocator argument to handleNotifications (sorry I mistakenly wrote requestNotifications before) should be the only init interface change needed for simultaneous rescanning.

The WalletInitInterface::Construct call shouldn't be affected and isn't directly involved in loading wallets. The Construct method is only responsible for parsing -wallet and -disablewallet options and constructing WalletClientImpl objects. Wallet loading happens later when WalletClientImpl::load is called.

@promag promag force-pushed the 2019-05-null-completer branch from 727143b to 2d8ad2f Compare May 30, 2019 22:26
@fanquake fanquake added this to the 0.18.1 milestone May 31, 2019
@fanquake
Copy link
Member

tACK 2d8ad2f on macOS.

Using master (c7cfd20) it's possible to cause a crash during startup by opening Window -> Console typing anything into the console and hitting enter.

lldb Bitcoin-Qt.app
(lldb) target create "Bitcoin-Qt.app"
Current executable set to 'Bitcoin-Qt.app' (x86_64).
(lldb) run
Process 59937 launched: '/Users/michael/github/bitcoin/Bitcoin-Qt.app/Contents/MacOS/Bitcoin-Qt' (x86_64)
2019-05-31 09:53:29.580881-0400 Bitcoin-Qt[59937:3647765] MessageTracer: Falling back to default whitelist
Process 59937 stopped
* thread #1, name = 'bitcoin-main', queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x8)
    frame #0: 0x00000001011a78ba QtWidgets`QCompleter::popup() const + 10
QtWidgets`QCompleter::popup:
->  0x1011a78ba <+10>: movq   0x8(%rdi), %rbx
    0x1011a78be <+14>: movq   0x88(%rbx), %rax
    0x1011a78c5 <+21>: testq  %rax, %rax
    0x1011a78c8 <+24>: jne    0x1011a7942               ; <+146>
Target 0: (Bitcoin-Qt) stopped.

Using this PR (2d8ad2f), it's still possible to get to the console during startup, but it's impossible to enter or execute any commands. The console is enabled when startup completes.

@laanwj laanwj merged commit 2d8ad2f into bitcoin:master Jun 3, 2019
laanwj added a commit that referenced this pull request Jun 3, 2019
2d8ad2f gui: Enable console line edit on setClientModel (João Barbosa)

Pull request description:

  Make console line edit disable by default, and only enable once `RPCConsole::setClientModel` is called.

  Fixes #16119.

ACKs for commit 2d8ad2:
  fanquake:
    tACK 2d8ad2f on macOS.

Tree-SHA512: 1418ce3c120c08e5ec3e7a7a063572a24402ce0ec541bd4adc21f61d60c4e86b711e82e940ebf5f0445ab861f89c146c2a2e7990fb52bed2c65fc199a1981f71
@promag promag deleted the 2019-05-null-completer branch June 3, 2019 20:43
@promag promag mentioned this pull request Jun 6, 2019
maflcko pushed a commit to maflcko/bitcoin-core that referenced this pull request Jun 7, 2019
HashUnlimited pushed a commit to HashUnlimited/chaincoin that referenced this pull request Aug 23, 2019
Bushstar pushed a commit to Bushstar/omnicore that referenced this pull request Aug 24, 2019
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 8, 2020
Summary:
It was possible to cause bitcoin-qt to crash by executing any command in menu `Window` > `Console` during startup.
This is fixed by disabling console line edit by default, and only enabling once `RPCConsole::setClientModel` is called.

Backport of Core [[bitcoin/bitcoin#16122 | PR16122]]

Test Plan:
`ninja && ninja check`

Note: I wasn't able to reproduce the crash, I'm not able to reach the menu before the application is well started.
But I tested that the console is still usable after this diff.

Reviewers: O1 Bitcoin ABC, #bitcoin_abc, deadalnix

Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D7803
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jul 1, 2021
2d8ad2f gui: Enable console line edit on setClientModel (João Barbosa)

Pull request description:

  Make console line edit disable by default, and only enable once `RPCConsole::setClientModel` is called.

  Fixes bitcoin#16119.

ACKs for commit 2d8ad2:
  fanquake:
    tACK bitcoin@2d8ad2f on macOS.

Tree-SHA512: 1418ce3c120c08e5ec3e7a7a063572a24402ce0ec541bd4adc21f61d60c4e86b711e82e940ebf5f0445ab861f89c146c2a2e7990fb52bed2c65fc199a1981f71
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jul 12, 2021
2d8ad2f gui: Enable console line edit on setClientModel (João Barbosa)

Pull request description:

  Make console line edit disable by default, and only enable once `RPCConsole::setClientModel` is called.

  Fixes bitcoin#16119.

ACKs for commit 2d8ad2:
  fanquake:
    tACK bitcoin@2d8ad2f on macOS.

Tree-SHA512: 1418ce3c120c08e5ec3e7a7a063572a24402ce0ec541bd4adc21f61d60c4e86b711e82e940ebf5f0445ab861f89c146c2a2e7990fb52bed2c65fc199a1981f71
@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.

gui: crash when running console commands during startup

4 participants