qt: Poll ShutdownTimer after init is done #12377

pull MarcoFalke wants to merge 1 commits into bitcoin:master from MarcoFalke:Mf1802-qtInitShutdown changing 1 files +1 −1
  1. MarcoFalke commented at 2:06 pm on February 7, 2018: member

    The shutdown process has started in requestShutdown, but initialize will happily continue with initializeResult and start threads late in the shutdown progess. Deleting this running thread will crash the application according to the qt docs: https://github.com/qt/qtbase/blob/e5033a5c9b769815112e922d0b224af860afd219/src/corelib/thread/qthread.cpp#L412-L415

    Potential fix for #12372 (comment)

    This reverts #11831 for now and hopefully restores the previous behaviour.

  2. MarcoFalke added the label GUI on Feb 7, 2018
  3. in src/qt/bitcoin.cpp:470 in fa3024b8df outdated
    466@@ -467,8 +467,7 @@ void BitcoinApplication::initializeResult(bool success)
    467     qDebug() << __func__ << ": Initialization result: " << success;
    468     // Set exit result.
    469     returnValue = success ? EXIT_SUCCESS : EXIT_FAILURE;
    470-    if(success)
    471-    {
    472+    if (success && !ShutdownRequested()) {
    


    laanwj commented at 2:10 pm on February 7, 2018:
    I’m not convinced that this makes a difference at all. initialzeResult is emitted with the return value of appInitMain. The return value of appInitMain (“success”) is supposed to be false when shutdown was requested during initialization.

    promag commented at 3:08 pm on February 7, 2018:
    It can make a difference if shutdown is requested between AppInitMain() returns and when this slot is executed, it’s a QueuedConnection.

    MarcoFalke commented at 3:10 pm on February 7, 2018:

    Maybe

     0diff --git a/src/init.cpp b/src/init.cpp
     1index 50643ff96b..1f46e5e3d2 100644
     2--- a/src/init.cpp
     3+++ b/src/init.cpp
     4@@ -1736,5 +1736,5 @@ bool AppInitMain()
     5     StartWallets(scheduler);
     6 #endif
     7 
     8-    return true;
     9+    return !ShutdownRequested();
    10 }
    

    promag commented at 3:19 pm on February 7, 2018:
    Indeed AppInitMain() return was changed recently in #11831, but I still think that is correct. IMO this change is also correct, it avoids initialization but the application should not crash without this change, so I don’t agree it’s a fix.

    laanwj commented at 4:26 pm on February 7, 2018:

    It can make a difference if shutdown is requested between AppInitMain() returns and when this slot is executed, it’s a QueuedConnection.

    Then after AppInitMain was successfully executed, a shutdown was requested (but not yet acted on), so I don’t understand why going into qt initialization would crash. It could successfully shutdown after that.

    But anyhow if this fixes a reproducible issue I’m okay with it, it’s possible that there are interactions I don’t follow.


    promag commented at 4:39 pm on February 7, 2018:

    so I don’t understand why going into qt initialization would crash

    That’s why I think this doesn’t fix the problem, just avoids it.


    laanwj commented at 5:21 pm on February 7, 2018:
    That’s good enough for rc3, though.
  4. laanwj added this to the milestone 0.16.0 on Feb 7, 2018
  5. laanwj commented at 5:57 pm on February 7, 2018: member

    If you have means to reproduce the underlying issue, what might also work is moving the shutdown detection to only start after the GUI side of the initialization. E.g. move

    0    pollShutdownTimer->start(200);
    

    from BitcoinApplication::createWindow to BitcoinApplication::initializeResult (in the if(success)). This makes sure that no special action is undertaken if request shutdown is detected while initialization and avoids the race.

  6. MarcoFalke force-pushed on Feb 7, 2018
  7. MarcoFalke renamed this:
    qt: Avoid initialization during shutdown
    Revert "Always return true if AppInitMain got to the end"
    on Feb 7, 2018
  8. qt: Poll ShutdownTimer after init is done 2222bf02c9
  9. MarcoFalke force-pushed on Feb 7, 2018
  10. MarcoFalke renamed this:
    Revert "Always return true if AppInitMain got to the end"
    qt: Poll ShutdownTimer after init is done
    on Feb 7, 2018
  11. MarcoFalke commented at 10:12 pm on February 7, 2018: member
    Changed to @laanwj suggestion
  12. laanwj commented at 7:51 am on February 8, 2018: member
    utACK 2222bf0
  13. laanwj merged this on Feb 8, 2018
  14. laanwj closed this on Feb 8, 2018

  15. laanwj referenced this in commit 36a927c525 on Feb 8, 2018
  16. laanwj added the label Needs backport on Feb 8, 2018
  17. laanwj referenced this in commit 604f289f71 on Feb 8, 2018
  18. laanwj removed the label Needs backport on Feb 8, 2018
  19. MarcoFalke deleted the branch on Feb 12, 2018
  20. HashUnlimited referenced this in commit ef630d734b on Mar 16, 2018
  21. ccebrecos referenced this in commit e6b37c5d70 on Sep 14, 2018
  22. deadalnix referenced this in commit 4a2ad75ca9 on Feb 15, 2019
  23. PastaPastaPasta referenced this in commit 6b32a15735 on Mar 14, 2020
  24. PastaPastaPasta referenced this in commit bf1d2cecbd on Mar 14, 2020
  25. PastaPastaPasta referenced this in commit 7e5c5d40d1 on Mar 15, 2020
  26. random-zebra referenced this in commit 1fbf681019 on Mar 6, 2021
  27. ckti referenced this in commit 1a7a939e50 on Mar 28, 2021
  28. DrahtBot locked this on Sep 8, 2021


MarcoFalke laanwj promag meshcollider

Labels
GUI

Milestone
0.16.0


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: 2024-06-18 22:12 UTC

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