gui: Fix boost::signals2::no_slots_error in early calls to InitWarning #14783

pull promag wants to merge 2 commits into bitcoin:master from promag:2018-11-fix-noslotserror changing 2 files +5 −12
  1. promag commented at 12:24 PM on November 22, 2018: member

    Adding the following to bitcoin.conf

    [xxx]
    disablewallet=1
    

    And running bitcoin-qt gives:

    libc++abi.dylib: terminating with uncaught exception of type boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::signals2::no_slots_error> >: boost::signals2::no_slots_error
    

    Fixes regression in #14708.

  2. in src/qt/bitcoin.cpp:696 in efb9276d47 outdated
     690 | @@ -691,6 +691,10 @@ int main(int argc, char *argv[])
     691 |  #endif
     692 |      // Install qDebug() message handler to route to debug.log
     693 |      qInstallMessageHandler(DebugMessageHandler);
     694 | +
     695 | +    // Redundantly log and print message in non-gui fashion
     696 | +    auto handler_message_box = node->handleMessageBox(noui_ThreadSafeMessageBox);
    


    laanwj commented at 12:26 PM on November 22, 2018:

    why assign this to a variable when it's not going to be used?


    promag commented at 12:29 PM on November 22, 2018:

    Internally handler_message_box has a boost::signals2::scoped_connection and the destructor disconnects.


    laanwj commented at 12:30 PM on November 22, 2018:

    might want to mention this in the comment, that is quite the gotcha

  3. promag commented at 12:31 PM on November 22, 2018: member

    Alternatively could call noui_connect in src/qt/bitcoin.cpp?

  4. laanwj commented at 12:34 PM on November 22, 2018: member

    I think the safest solution to this is to not call the message box at all for unrecognized sections. Simply call LogPrintf directly. That's what will happen after all!

  5. fanquake added the label GUI on Nov 22, 2018
  6. promag force-pushed on Nov 22, 2018
  7. promag renamed this:
    qt: Fix boost::signals2::no_slots_error in early calls to InitWarning
    Replace early calls to InitWarning by LogPrintf
    on Nov 22, 2018
  8. promag commented at 12:54 PM on November 22, 2018: member

    Updated, @MarcoFalke you might want to check this out since you reviewed #14708.

  9. laanwj commented at 12:57 PM on November 22, 2018: member

    Concept ACK

    So to be clear, the problem is that at this stage of initialization, we're not yet able to show message boxes in Qt [1]. @promag's initial fix changed the slot handler to first register a message box handler that only logs, but, it seems safer to simply change these InitWarning calls to LogPrintf as that's what is going to happen both for the UI and bitcoind.

    1. The reason is that there are some things concerning locale and language setup that only can run after configuration parsing, after which the main UI window is created. It might be possible to refactor this at some point but for fixing the issue, this is the safer option.
  10. promag force-pushed on Nov 22, 2018
  11. promag force-pushed on Nov 22, 2018
  12. promag renamed this:
    Replace early calls to InitWarning by LogPrintf
    Replace early calls to InitWarning with fprintf(stderr, ...)
    on Nov 22, 2018
  13. Empact commented at 2:24 PM on November 22, 2018: member

    ~May as well match the form of the other warnings in this function, no? They print a leading LogPrintf("%s: ...", __func__, ...).~

  14. promag commented at 2:26 PM on November 22, 2018: member

    Now using fprintf(stderr, ...) Instead of LogPrintf so that test/functional/feature_config_args.py passes.

  15. in src/init.cpp:813 in 91ce5a2f5d outdated
     810 |      }
     811 |  
     812 |      // Warn if unrecognized section name are present in the config file.
     813 |      for (const auto& section : gArgs.GetUnrecognizedSections()) {
     814 | -        InitWarning(strprintf(_("Section [%s] is not recognized."), section));
     815 | +        fprintf(stderr, "Warning: Section [%s] is not recognized.\n", section.c_str());
    


    MarcoFalke commented at 5:21 PM on November 22, 2018:

    InitWarning also prints to the debug log, fprintf does not.

  16. MarcoFalke dismissed
  17. MarcoFalke commented at 5:26 PM on November 22, 2018: member

    Slightly tend to NACK. This makes the code fragile in light of refactoring such as move-only commits, since it is not clear when InitWarning is safe to call. Wouldn't it be easier to always register the no_ui listener to the signal as soon as possible in the initialization sequence (regardless of bitcoind vs bitcoin-qt) and then optionally, if the gui is run, also register the gui message box listener?

    Side-note: Previously we wouldn't even log nor print warnings when running the gui, but that is now fixed (see #14162)

  18. qt: Call noui_connect to prevent boost::signals2::no_slots_error in early calls to InitWarning a0f8df365d
  19. promag force-pushed on Nov 22, 2018
  20. promag commented at 5:46 PM on November 22, 2018: member

    Previous fix in 91ce5a2, which @MarcoFalke disapproved.

    Current fix does what was suggested in #14783 (comment).

  21. promag renamed this:
    Replace early calls to InitWarning with fprintf(stderr, ...)
    Fix boost::signals2::no_slots_error in early calls to InitWarning
    on Nov 22, 2018
  22. MarcoFalke renamed this:
    Fix boost::signals2::no_slots_error in early calls to InitWarning
    gui: Fix boost::signals2::no_slots_error in early calls to InitWarning
    on Nov 22, 2018
  23. promag commented at 8:52 PM on November 22, 2018: member

    Not sure about this because I think it should go thru interfaces::Node?

  24. MarcoFalke commented at 9:24 PM on November 22, 2018: member

    Should remove the now-redundant (?) static void InitMessage in src/qt/bitcoin.cpp?

  25. laanwj commented at 7:48 AM on November 23, 2018: member

    I'm still not sure about this, but ok…

    For example:

    • Does noui_register register anything else that might interfere with the GUI?
    • What about the return argument of ThreadSafeMessageBox, will registering multiple handlers cause an issue here (similar for other handlers that noui_register registers)
  26. promag commented at 7:58 AM on November 23, 2018: member

    @laanwj I'm not ignoring them, I'm trying to address them.

  27. promag commented at 3:37 PM on November 23, 2018: member

    @laanwj you mean noui_connect instead of noui_register. Regarding:

    • Does noui_register register anything else that might interfere with the GUI?

    noui_connect only connects 3 slots that only call LogPrintf and fprintf, so I think we are safe.

    • What about the return argument of ThreadSafeMessageBox, will registering multiple handlers cause an issue here (similar for other handlers that noui_register registers)

    In boost::signals, slot results are combined to give the signal result. The default combiner is to give the last slot result. So the first connected slots are those in noui_connect and later are the UI slots, which means the signal result comes from the UI slots. So it's safe to say there is no behavior change.

  28. DrahtBot commented at 7:10 PM on November 23, 2018: member

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #11625 (Add BitcoinApplication & RPCConsole tests by ryanofsky)

    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.

  29. squashme: connect thru node interface 6bbdb2077e
  30. in src/qt/bitcoin.cpp:564 in bdf4d5586d outdated
     557 | @@ -563,6 +558,11 @@ int main(int argc, char *argv[])
     558 |  
     559 |      std::unique_ptr<interfaces::Node> node = interfaces::MakeNode();
     560 |  
     561 | +    // Subscribe to global signals from core
     562 | +    std::unique_ptr<interfaces::Handler> handler = node->handleMessageBox(noui_ThreadSafeMessageBox);
     563 | +    std::unique_ptr<interfaces::Handler> handler = node->handleQuestion(noui_ThreadSafeQuestion);
     564 | +    std::unique_ptr<interfaces::Handler> handler = node->handleInitMessage(noui_InitMessage);
    


    MarcoFalke commented at 11:47 PM on November 23, 2018:

    This does not compile.


    promag commented at 3:18 PM on November 25, 2018:

    Fixed.

  31. promag force-pushed on Nov 24, 2018
  32. jonasschnelli commented at 5:42 AM on November 25, 2018: contributor

    Concept ACK

  33. promag commented at 3:19 PM on November 25, 2018: member

    Should remove the now-redundant (?) static void InitMessage in src/qt/bitcoin.cpp? @MarcoFalke done.

  34. in src/qt/bitcoin.cpp:566 in 6bbdb2077e
     557 | @@ -563,6 +558,11 @@ int main(int argc, char *argv[])
     558 |  
     559 |      std::unique_ptr<interfaces::Node> node = interfaces::MakeNode();
     560 |  
     561 | +    // Subscribe to global signals from core
     562 | +    std::unique_ptr<interfaces::Handler> handler_message_box = node->handleMessageBox(noui_ThreadSafeMessageBox);
     563 | +    std::unique_ptr<interfaces::Handler> handler_question = node->handleQuestion(noui_ThreadSafeQuestion);
     564 | +    std::unique_ptr<interfaces::Handler> handler_init_message = node->handleInitMessage(noui_InitMessage);
     565 | +
     566 |      // Do not refer to data directory yet, this can be overridden by Intro::pickDataDirectory
    


    MarcoFalke commented at 5:36 PM on November 26, 2018:

    What makes it safe to subscribe to them here already, when some of then log to the debug log, which is in the datadir?


    promag commented at 3:30 PM on November 27, 2018:

    If that was the case then boost::signals2::no_slots_error would have been raised before?

  35. MarcoFalke commented at 7:37 PM on November 27, 2018: member

    utACK 6bbdb2077eb4dae9f7a1938bdbcffab884719cbe. Going to test the next time I compile the gui

  36. Sjors commented at 3:38 PM on December 6, 2018: member

    I can reproduce the error on macOS 10.14.1 and confirm 6bbdb20 fixes it. It shows a Section [xxx] is not recognized. after the command, but someone launching QT via a desktop icon wouldn't see that.

    Would be nice to have to test, though that might require #11625

  37. promag commented at 3:44 PM on December 6, 2018: member

    @Sjors thanks, and the improvement can come next.

  38. MarcoFalke referenced this in commit f8456256c8 on Dec 6, 2018
  39. MarcoFalke merged this on Dec 6, 2018
  40. MarcoFalke closed this on Dec 6, 2018

  41. deadalnix referenced this in commit 1b7b18cbca on Apr 22, 2020
  42. ftrader referenced this in commit cf3bdb5933 on Aug 17, 2020
  43. linuxsh2 referenced this in commit e3f0da1972 on Jul 29, 2021
  44. linuxsh2 referenced this in commit 3a1cf20f89 on Jul 30, 2021
  45. Munkybooty referenced this in commit 8fc5406d4d on Aug 2, 2021
  46. linuxsh2 referenced this in commit d4442aca01 on Aug 3, 2021
  47. Munkybooty referenced this in commit 7ed965e9f9 on Aug 3, 2021
  48. Munkybooty referenced this in commit 849d08cc44 on Aug 5, 2021
  49. Munkybooty referenced this in commit 669093adb2 on Aug 5, 2021
  50. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

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: 2026-04-13 21:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me