Skip to content

Conversation

@furszy
Copy link
Member

@furszy furszy commented Dec 26, 2022

The app currently crashes if a network is set inside bitcoin.conf and
another one is provided as param.
The reason is an uncaught runtime_error.

We shouldn't crash if a network is set inside
bitcoin.conf and another one is provided as param.
@DrahtBot
Copy link
Contributor

DrahtBot commented Dec 26, 2022

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK jarolrod, johnny9, john-moffett, pablomartin4btc, hebasto
Concept ACK hernanmarino

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Copy link
Contributor

@jarolrod jarolrod left a comment

Choose a reason for hiding this comment

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

tACK f4a11d7

Reproduced the crash on master by passing in a chain param while my bitcoin.conf specified a different chain:

master

libc++abi: terminating with uncaught exception of type std::runtime_error: Invalid combination of -regtest, -signet, -testnet and -chain. Can use at most one.
[1]    53813 abort      ./src/qt/bitcoin-qt -signet

Screen Shot 2022-12-28 at 10 30 47 AM

The PR branch fixes the issue for me:

pr

Error: Invalid combination of -regtest, -signet, -testnet and -chain. Can use at most one.

Screen Shot 2022-12-28 at 10 30 00 AM

Also tested the scenario where we show the intro to choose a datadir and a network parameter is passed; crash on master, fixed in pr branch.

Copy link
Contributor

@johnny9 johnny9 left a comment

Choose a reason for hiding this comment

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

tACK f4a11d7

Tested the changes with the following method.

  1. Set bitcoin.conf to testnet
// /home/user/.bitcoin/bitcoin.conf
testnet=1
  1. ran bitcoin-qt with the following command bitcoin-qt -signet

On masterr (e9262ea):

~/github/gui$ ./src/qt/bitcoin-qt -signet                                                                                                                                                                                            
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
terminate called after throwing an instance of 'std::runtime_error'
  what():  Invalid combination of -regtest, -signet, -testnet and -chain. Can use at most one.
Aborted (core dumped)

With PR (f4a11d7):

~/github/gui$ ./src/qt/bitcoin-qt -signet
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
Error: Invalid combination of -regtest, -signet, -testnet and -chain. Can use at most one.

And the following error dialog also appears now:
Screenshot from 2022-12-28 19-09-41

The change expands the try block to handle the exception thrown from GetChainName and is a reasonable approach to handling the error and giving the user expected gui error dialog. Some follow up to this bug might include functional test coverage with the settings testcases to prevent regression. Another possible follow up is to handle the exception within ReadConfigFiles so bitcoind doesn't abort from the runtime_error.

Copy link
Contributor

@hernanmarino hernanmarino left a comment

Choose a reason for hiding this comment

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

Tested ACK. Also fails on master and succeds on PR.

@jarolrod jarolrod added the Bug Something isn't working label Jan 3, 2023
Copy link
Contributor

@john-moffett john-moffett left a comment

Choose a reason for hiding this comment

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

ACK f4a11d7

Copy link
Contributor

@pablomartin4btc pablomartin4btc left a comment

Choose a reason for hiding this comment

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

Tested ACK f4a11d7.
It behaves as expected, tested using different networks before and after the fix.
I agree with @johnny9 on functional tests if possible as a follow up ofc.

@furszy
Copy link
Member Author

furszy commented Jan 9, 2023

@hebasto

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

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

ACK f4a11d7, tested on Ubuntu 22.04 (Qt 5.15.3).

@hebasto hebasto changed the title bugfix, catch invalid networks combination crash Catch invalid networks combination crash Jan 15, 2023
@hebasto hebasto merged commit 3dd2762 into bitcoin-core:master Jan 15, 2023
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jan 16, 2023
@bitcoin-core bitcoin-core locked and limited conversation to collaborators Jan 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants