Qt: remove macOS launch-at-startup when compiled with > macOS 10.11, fix memory missmanagement #15208

pull jonasschnelli wants to merge 2 commits into bitcoin:master from jonasschnelli:2019/01/macos_autostart changing 3 files +23 −11
  1. jonasschnelli commented at 8:04 AM on January 19, 2019: contributor

    The launch-at-startup API Bitcoin Core uses on macOS where removed in macOS 10.11 leading to a segmentation-fault due to the weak-linking when not actively compiled against SDK 10.11 (-mmacosx-version-min=10.11)

    This PR removes the launch-at-startup feature on macOS when compiled with macOS min version > 10.11 (the default is always the macOS version you compile on).

    The depends built binaries (Gitian) are not affected since we are building with min macOS 10.10.

    Users self compiling on macOS > 10.11 can re-enable the feature by compiling with min version <= 10.11 (CXXFLAGS="-mmacosx-version-min=10.11" CFLAGS="-mmacosx-version-min=10.11" ./configure)

    Isn't there a new API from Apple? Yes, there is. It will require to create a helper application which needs to be embedded in the .app folder (needs code signing as well). Developers willing to go down that rabbit hole are welcome.

    Fixes #15142

  2. jonasschnelli added the label macOS on Jan 19, 2019
  3. hebasto commented at 8:39 AM on January 19, 2019: member

    utACK 8441c90af88fb0f08762cf56e508803ed4b47d4c modulo typo

  4. in doc/release-notes.md:265 in 8441c90af8 outdated
     261 | @@ -262,6 +262,11 @@ Graphical User Interface (GUI)
     262 |    balance shown if the wallet was created using the `createwallet` RPC
     263 |    and the `disable_private_keys` parameter was set to true.
     264 |  
     265 | +- The launch-on-startup option in no longer available on macOS if
    


    hebasto commented at 8:41 AM on January 19, 2019:

    in --> is ?

  5. laanwj commented at 12:27 PM on January 19, 2019: member

    utACK

  6. fanquake commented at 3:30 AM on January 20, 2019: member

    Compiling 8441c90 on macOS 10.14.2:

    ./autogen.sh && ./configure && make check -j6
    

    The option is disabled. <img width="655" alt="pr - no 10 11" src="https://user-images.githubusercontent.com/863730/51434776-8057de80-1ca3-11e9-9a32-0fdf04ae19e9.png">

    However, when passing -mmacosx-version-min=10.11 to ./configure:

    ./autogen.sh
    CXXFLAGS="-mmacosx-version-min=10.11" CFLAGS="-mmacosx-version-min=10.11" ./configure
    make check -j6
    lldb src/qt/bitcoin-qt
    

    I'm still seeing the same segfault behaviour as #15142:

    Current executable set to 'src/qt/bitcoin-qt' (x86_64).
    (lldb) run
    Process 20678 launched: '/Users/michael/github/bitcoin/src/qt/bitcoin-qt' (x86_64)
    2019-01-20 11:09:45.261118+0800 bitcoin-qt[20678:2180338] MessageTracer: Falling back to default whitelist
    Process 20678 stopped
    * thread [#1](/bitcoin-bitcoin/1/), queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x20)
        frame [#0](/bitcoin-bitcoin/0/): 0x00007fff72cb58bf libobjc.A.dylib`objc_retain + 31
    libobjc.A.dylib`objc_retain:
    ->  0x7fff72cb58bf <+31>: testb  $0x4, 0x20(%rcx)
        0x7fff72cb58c3 <+35>: je     0x7fff72cb58f6            ; <+86>
        0x7fff72cb58c5 <+37>: testb  $0x1, %al
        0x7fff72cb58c7 <+39>: je     0x7fff72cb58e9            ; <+73>
    Target 0: (bitcoin-qt) stopped.
    (lldb) bt
    * thread [#1](/bitcoin-bitcoin/1/), queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x20)
      * frame [#0](/bitcoin-bitcoin/0/): 0x00007fff72cb58bf libobjc.A.dylib`objc_retain + 31
        frame [#1](/bitcoin-bitcoin/1/): 0x00007fff484b8f18 SharedFileList`-[SFLLoginItemList removeItem:error:] + 35
        frame [#2](/bitcoin-bitcoin/2/): 0x00007fff484bf3c7 SharedFileList`LSSharedFileListItemRemove + 127
        frame [#3](/bitcoin-bitcoin/3/): 0x000000010007041f bitcoin-qt`GUIUtil::SetStartOnSystemStartup(bool) + 223
        frame [#4](/bitcoin-bitcoin/4/): 0x00000001000a25fa bitcoin-qt`OptionsModel::setData(QModelIndex const&, QVariant const&, int) + 202
        frame [#5](/bitcoin-bitcoin/5/): 0x000000010241a7a7 QtWidgets`QItemDelegate::setModelData(QWidget*, QAbstractItemModel*, QModelIndex const&) const + 295
        frame [#6](/bitcoin-bitcoin/6/): 0x0000000102423b48 QtWidgets`___lldb_unnamed_symbol4564$$QtWidgets + 248
        frame [#7](/bitcoin-bitcoin/7/): 0x0000000102424c7b QtWidgets`QDataWidgetMapper::submit() + 59
        frame [#8](/bitcoin-bitcoin/8/): 0x000000010009573b bitcoin-qt`OptionsDialog::on_okButton_clicked() + 43
        frame [#9](/bitcoin-bitcoin/9/): 0x00000001001e0f9a bitcoin-qt`OptionsDialog::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) + 202
        frame [#10](/bitcoin-bitcoin/10/): 0x00000001001e136b bitcoin-qt`OptionsDialog::qt_metacall(QMetaObject::Call, int, void**) + 139
        frame [#11](/bitcoin-bitcoin/11/): 0x0000000102e79bbd QtCore`QMetaObject::activate(QObject*, int, int, void**) + 1773
        frame [#12](/bitcoin-bitcoin/12/): 0x000000010227aacf QtWidgets`___lldb_unnamed_symbol1034$$QtWidgets + 111
        frame [#13](/bitcoin-bitcoin/13/): 0x000000010227a96c QtWidgets`___lldb_unnamed_symbol1032$$QtWidgets + 236
        frame [#14](/bitcoin-bitcoin/14/): 0x000000010227ba9f QtWidgets`QAbstractButton::mouseReleaseEvent(QMouseEvent*) + 271
    
  7. jonasschnelli commented at 8:58 PM on January 20, 2019: contributor

    @fanquake: your right. There is something wrong with our implementation... I'll fix that soon.

  8. jonasschnelli force-pushed on Jan 21, 2019
  9. jonasschnelli renamed this:
    Qt: remove macOS launch-at-startup when compiled with > macOS 10.11
    Qt: remove macOS launch-at-startup when compiled with > macOS 10.11, fix memory missmanagement
    on Jan 21, 2019
  10. jonasschnelli commented at 6:39 AM on January 21, 2019: contributor

    Current macOS launch at login code does release an item which belongs to an array that gets release later (double release) which causes a crash on certain macOS versions.

    I added a commit that fixes the memory mismanagement.

  11. in doc/release-notes.md:267 in 541d287b80 outdated
     261 | @@ -262,6 +262,11 @@ Graphical User Interface (GUI)
     262 |    balance shown if the wallet was created using the `createwallet` RPC
     263 |    and the `disable_private_keys` parameter was set to true.
     264 |  
     265 | +- The launch-on-startup option is no longer available on macOS if
     266 | +  compiled with macosx min version greater then 10.11 (use
     267 | +  CXXFLAGS="-mmacosx-version-min=10.11" for setting the deployment
    


    hebasto commented at 9:39 AM on January 21, 2019:

    CFLAGS="-mmacosx-version-min=10.11" could be added as well. Without CFLAGS there are linker warnings: screenshot from 2019-01-21 11-38-04

  12. in src/qt/guiutil.cpp:689 in 541d287b80 outdated
     687 | +#elif defined(Q_OS_MAC) && defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED <= 101100
     688 |  // based on: https://github.com/Mozketo/LaunchAtLoginController/blob/master/LaunchAtLoginController.m
     689 |  
     690 | -LSSharedFileListItemRef findStartupItemInList(LSSharedFileListRef list, CFURLRef findUrl);
     691 | -LSSharedFileListItemRef findStartupItemInList(LSSharedFileListRef list, CFURLRef findUrl)
     692 | +LSSharedFileListItemRef findStartupItemInList(CFArrayRef listSnapshot, LSSharedFileListRef list, CFURLRef findUrl);
    


    hebasto commented at 9:41 AM on January 21, 2019:

    This function declaration seems unnecessary. Could it be removed?

  13. in src/qt/guiutil.cpp:738 in 541d287b80 outdated
     736 | +    bool res = (findStartupItemInList(listSnapshot, loginItems, bitcoinAppUrl) != nullptr);
     737 |      CFRelease(bitcoinAppUrl);
     738 | -    return !!foundItem; // return boolified object
     739 | +    CFRelease(loginItems);
     740 | +    CFRelease(listSnapshot);
     741 | +    return res; // return boolified object
    


    hebasto commented at 9:45 AM on January 21, 2019:

    res is a bool already. Could the comment be removed?

  14. hebasto changes_requested
  15. hebasto commented at 9:45 AM on January 21, 2019: member

    Tested 541d287b805ecaad1d9810b5a776d2e0d8b87233 on macOS 10.13.6.

  16. jonasschnelli force-pushed on Jan 21, 2019
  17. jonasschnelli commented at 6:28 PM on January 21, 2019: contributor

    Fixed @hebasto findings

  18. hebasto commented at 8:43 PM on January 21, 2019: member

    tACK 35f5cb791de6bd47b62e031a74d885f00efd2585 (macOS 10.13.6 + Qt 5.11.2)

    The depends built binaries (Gitian) are not affected since we are building with min macOS 10.10.

    Note: official v0.17.1 is affected. Could backport?

  19. Qt: remove macOS launch-at-startup option when compiled with > macOS 10.11 516437a1b7
  20. Fix macOS launch-at-startup memory issue da6011826a
  21. in doc/release-notes.md:266 in 35f5cb791d outdated
     261 | @@ -262,6 +262,12 @@ Graphical User Interface (GUI)
     262 |    balance shown if the wallet was created using the `createwallet` RPC
     263 |    and the `disable_private_keys` parameter was set to true.
     264 |  
     265 | +- The launch-on-startup option is no longer available on macOS if
     266 | +  compiled with macosx min version greater then 10.11 (use
    


    practicalswift commented at 8:36 AM on January 22, 2019:

    Should be "greater than" :-)


    jonasschnelli commented at 8:43 AM on January 22, 2019:

    Fixed.

  22. jonasschnelli force-pushed on Jan 22, 2019
  23. laanwj commented at 9:52 PM on January 22, 2019: member

    utACK da6011826a730837b59aef5664f3feab4787c9bc

  24. laanwj merged this on Jan 22, 2019
  25. laanwj closed this on Jan 22, 2019

  26. laanwj referenced this in commit 94167e2b5b on Jan 22, 2019
  27. fanquake referenced this in commit 27d82b63fb on Nov 22, 2019
  28. fanquake referenced this in commit 4fb82e916b on Nov 26, 2019
  29. sidhujag referenced this in commit 04359028bb on Nov 27, 2019
  30. HashUnlimited referenced this in commit e5a4fcad33 on Apr 17, 2020
  31. jasonbcox referenced this in commit 945c3d3bc5 on Nov 5, 2020
  32. sidhujag referenced this in commit d18a192f24 on Nov 10, 2020
  33. backpacker69 referenced this in commit ad83e1f997 on Mar 28, 2021
  34. furszy referenced this in commit 92bea4034e on Jul 6, 2021
  35. kittywhiskers referenced this in commit 04da571f4b on Jul 15, 2021
  36. kittywhiskers referenced this in commit 94eb32b8aa on Jul 15, 2021
  37. kittywhiskers referenced this in commit 925a435ed5 on Jul 20, 2021
  38. kittywhiskers referenced this in commit 34d6eb8960 on Jul 20, 2021
  39. kittywhiskers referenced this in commit 86b5d17fea on Jul 20, 2021
  40. kittywhiskers referenced this in commit bfdc94b31e on Aug 1, 2021
  41. kittywhiskers referenced this in commit bd280540ef on Aug 24, 2021
  42. kittywhiskers referenced this in commit caffb61961 on Aug 25, 2021
  43. kittywhiskers referenced this in commit 38bf71e1d2 on Aug 26, 2021
  44. kittywhiskers referenced this in commit 9db5c94a3d on Aug 27, 2021
  45. kittywhiskers referenced this in commit 839568fea9 on Aug 30, 2021
  46. kittywhiskers referenced this in commit def36ab1f4 on Aug 31, 2021
  47. MarcoFalke locked this on Dec 16, 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-21 18:15 UTC

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