Commit Graph

23552 Commits

Author SHA1 Message Date
Samuel Dobson
febebc4ea6 Fix WSL file locking by using flock instead of fcntl
Co-authored-by: sipa <pieter@wuille.net>

Github-Pull: #18700
Rebased-From: e8fa0a3d20
2020-06-09 21:09:22 +08:00
fanquake
5c7151a604 gui: update Qt base translations for macOS release
These haven't been updated since their addition, so this updates the list that
controls which qt base translations are bundled with the macOS binary, to all the
languages that are available with qt 5.9.8.

This could probably be improved in some way, however qt updates are infrequent,
and I didn't want to spend any more time looking at this. Also given that no-one
seems to have noticed and/or reported this it wouldn't seem high-priority.

Could be backported to 0.20.1.

Github-Pull: #19059
Rebased-From: 69bfcac27a
2020-06-09 21:08:32 +08:00
sachinkm77
c219d21634 build: improved output of configure for build OS
Github-Pull: #19152
Rebased-From: 0fef60c63d
2020-06-09 21:07:45 +08:00
MIZUTA Takeshi
0596a6eeb5 util: Don't reference errno when pthread fails.
Pthread library does not set errno.
Pthread library's errno is returned by return value.

Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>

Github-Pull: #19194
Rebased-From: cb38b069b0
2020-06-09 21:06:15 +08:00
MarcoFalke
cd32134bda Merge #19170: [0.20] Add missing QPainterPath include
384d3f991c Add missing QPainterPath include (Andrew Chow)

Pull request description:

  This is needed to compile with Qt 5.15.

  Github-Pull: #19097
  Rebased-From: 79b0a69e09

Top commit has no ACKs.

Tree-SHA512: 23c4604cddb0bf5955afa6dfb6be87989df591e5f5ca5b85257c72e916f29337012b24c9ab5374a3289700ab7518ddb48f21195a2173ea1f935d69bd2ad13b8b
2020-06-04 18:21:28 -04:00
Andrew Chow
384d3f991c Add missing QPainterPath include
This is needed to compile with Qt 5.15.

Github-Pull: #19097
Rebased-From: 79b0a69e09
2020-06-04 21:56:05 +00:00
MarcoFalke
e42c959c1d Merge #19019: [0.20] Fix GBT: Restore "!segwit" and "csv" to "rules" key
412d5fe879 QA: feature_segwit: Check that template "rules" includes "!segwit" as appropriate (Luke Dashjr)
2abe8cc3b7 Bugfix: Include "csv","!segwit" in "rules" (Luke Dashjr)

Pull request description:

  Original branch merges cleanly (no rebase needed)

  See also #17946

ACKs for top commit:
  jnewbery:
    utACK 412d5fe879

Tree-SHA512: 8b269f7782c10f02dc245cc377d91f594474eade6a32184a49fa2ed3928d91917e4b83eefee6947bfb5ffff54eca2781f8cf2169c1f0ad3fefca1d4b3cf304dd
2020-06-02 17:55:19 -04:00
Wladimir J. van der Laan
a62f0ed64f doc: Manpages update pre-final
Tree-SHA512: 00d03cb9913a7fe3fe90b12a866e88e08c79fdfdb05fcf043d77623b2d30cadd56557db1f225b428fd03d4b4bc4f24f66205d8330d025ed015d3a12dffd5222e
v0.20.0
2020-06-02 09:43:04 +02:00
Wladimir J. van der Laan
808c8d15fe build: Set rc to 0 for -final
Tree-SHA512: 07ec7c9f9f32aeb6249a406b4d1738a7f8c988d157ecd84a4eb13f3d86b9a6c6407d4c14669cc4cad5483e9b2f393693833adc8e9fbd3cc75311257ed6894652
2020-06-02 09:39:22 +02:00
fanquake
60e8e74d10 Merge #19138: doc: Merge 0.20.0 release notes from wiki
1dfad42595 doc: Merge 0.20.0 release notes from wiki (Wladimir J. van der Laan)

Pull request description:

  Need to do this before -final.

ACKs for top commit:
  fanquake:
    ACK 1dfad42595

Tree-SHA512: 5db5a9ed8860b78941ebf0e1d966564ac0e2914fd18fc0c2f4e7a32d78306c1bb1aa2fd416e1fb01d427ff69c698a019498fc94a6e580c5d84a53c0716e675f1
2020-06-02 14:14:17 +08:00
Wladimir J. van der Laan
1dfad42595 doc: Merge 0.20.0 release notes from wiki 2020-06-02 06:48:32 +02:00
Wladimir J. van der Laan
6f7f94a276 build: Bump RC to rc2
Tree-SHA512: c1bb2b3fb772704ab0266a30011869cb326608b731b1c7feaea107e1cbd0e67f7cf500ca4be36c705d8a3e6d7fcf324c52c062164d6ba315fbf0b99eed362b76
v0.20.0rc2
2020-05-15 14:19:14 +02:00
Wladimir J. van der Laan
0793eca3a6 qt: Pre-rc2 translations update
Tree-SHA512: 50d0605712273d661f22d0ded2f8010d69fd8baa94537419d3d0ff82bf5f407e6d7bce0e8cf8ff32a2d8e40feb224124f30e22c52b0f132c3a56128335a2593a
2020-05-15 14:13:03 +02:00
MarcoFalke
17bdf2afae Merge #18973: [0.20] Final backports for rc2
245c862cfd test: disable script fuzz tests (fanquake)
9a8fb4cf4b fuzz: Remove enumeration of expected deserialization exceptions in ProcessMessage(...) fuzzer (practicalswift)
6161c94a61 [net processing] Only send a getheaders for one block in an INV (John Newbery)
cf2a6e2a39 test: Remove const to work around compiler error on xenial (Wladimir J. van der Laan)
cc7d34465b miner: Avoid stack-use-after-return in validationinterface (MarcoFalke)
37a620748b test: Add unregister_validation_interface_race test (MarcoFalke)
ff4dc20750 gui: Fix manual coin control with multiple wallets loaded (João Barbosa)
ed0afe8c1f test: Add test for conflicted wallet tx notifications (Russell Yanofsky)
251e321ad7 rpc: Relock wallet only if most recent callback (João Barbosa)
ca4dac48c5 rpc: Add mutex to guard deadlineTimers (João Barbosa)
a3fe458a1e [docs] Improve commenting in ProcessGetData() (John Newbery)
011532e380 [test] test that an invalid GETDATA doesn't prevent processing of future messages (Amiti Uttarwar)
1e73d7248a [net processing] ignore unknown INV types in GETDATA messages (Amiti Uttarwar)
fb821731eb [net processing] ignore tx GETDATA from blocks-only peers (Amiti Uttarwar)
315ae14f3f gui: Fix itemWalletAddress leak when not tree mode (João Barbosa)

Pull request description:

  Backports the following PRs to the 0.20 branch:

  * https://github.com/bitcoin/bitcoin/pull/18578: gui: Fix leak in CoinControlDialog::updateView
  * https://github.com/bitcoin/bitcoin/pull/18808: [net processing] Drop unknown types in getdata
  * https://github.com/bitcoin/bitcoin/pull/18814: rpc: Relock wallet only if most recent callback
  * https://github.com/bitcoin/bitcoin/pull/18878: test: Add test for conflicted wallet tx notifications
  * https://github.com/bitcoin/bitcoin/pull/18894: gui: Fix manual coin control with multiple wallets loaded
  * https://github.com/bitcoin/bitcoin/pull/18742: miner: Avoid stack-use-after-return in validationinterface
  * https://github.com/bitcoin/bitcoin/pull/18962: net processing: Only send a getheaders for one block in an INV
  * https://github.com/bitcoin/bitcoin/pull/18975: test: Remove const to work around compiler error on xenial

ACKs for top commit:
  promag:
    Tested ACK 245c862cfd coin control with multiple wallets.
  laanwj:
    ACK 245c862cfd
  MarcoFalke:
    ACK 245c862cfd solved the conflicts myself as a sanity check. Did not re-review 🍷

Tree-SHA512: 285e5a5fad5bbeba6032742c65dc68836e8eccfcceda9e69fec4ddd162a3f61679a96f9bbe3d434267835af67c21ac4c05accf6f63e827c2eb47203c6daafe31
2020-05-15 07:54:36 -04:00
fanquake
245c862cfd test: disable script fuzz tests
Given that #18413 has not been backported.
2020-05-15 15:50:32 +08:00
practicalswift
9a8fb4cf4b fuzz: Remove enumeration of expected deserialization exceptions in ProcessMessage(...) fuzzer
Github-Pull: #18757
Rebased-From: fdceb63283
2020-05-15 12:03:50 +08:00
John Newbery
6161c94a61 [net processing] Only send a getheaders for one block in an INV
Headers-first is the primary method of announcement on the network. If a
node fell back sending blocks by inv, it's probably for a re-org. The
final block hash provided should be the highest, so send a getheaders
and then fetch the blocks we need to catch up.

Github-Pull: #18962
Rebased-From: 746736639e
2020-05-15 08:10:05 +08:00
Wladimir J. van der Laan
cf2a6e2a39 test: Remove const to work around compiler error on xenial
Fix the following error in travis:

    test/validationinterface_tests.cpp:26:36: error: default initialization of an object of const type 'const BlockValidationState' without a user-provided default constructor

    const BlockValidationState state_dummy;

Github-Pull: #18975
Rebased-From: 050e2ee6f2
2020-05-15 08:08:15 +08:00
MarcoFalke
cc7d34465b miner: Avoid stack-use-after-return in validationinterface
This is achieved by switching to a shared_ptr.

Also, switch the validationinterfaces in the tests to use shared_ptrs
for the same reason.

Github-Pull: #18742
Rebased-From: 7777f2a4bb
2020-05-15 07:42:08 +08:00
MarcoFalke
37a620748b test: Add unregister_validation_interface_race test
This commit is (intentionally) adding a broken test. The test is broken
because it registering a subscriber object that can go out of scope
while events are still being sent.

To run the broken test and reproduce the bug:
  - Remove comment /** and */
  - ./configure --with-sanitizers=address
  - export ASAN_OPTIONS=detect_leaks=0
  - make
  - while ./src/test/test_bitcoin -t validationinterface_tests/unregister_validation_interface_race --catch_system_errors=no  ; do true; done

Github-Pull: #18742
Rebased-From: fab6d060ce
2020-05-15 07:42:08 +08:00
João Barbosa
ff4dc20750 gui: Fix manual coin control with multiple wallets loaded
Github-Pull: #18894
Rebased-From: a8b5f1b133
2020-05-15 07:42:08 +08:00
Russell Yanofsky
ed0afe8c1f test: Add test for conflicted wallet tx notifications
Add test coverage for conflicted wallet transaction notifications so we improve
current behavior and avoid future regressions

https://github.com/bitcoin/bitcoin/pull/9240 - accidental break
https://github.com/bitcoin/bitcoin/issues/9479 - bug report
https://github.com/bitcoin/bitcoin/pull/9371 - fix
https://github.com/bitcoin/bitcoin/pull/16624 - accidental break
https://github.com/bitcoin/bitcoin/issues/18325 - bug report
https://github.com/bitcoin/bitcoin/pull/18600 - potential fix

Github-Pull: #18878
Rebased-From: f963a68051
2020-05-15 07:42:08 +08:00
João Barbosa
251e321ad7 rpc: Relock wallet only if most recent callback
Github-Pull: #18814
Rebased-From: 9f59dde974
2020-05-15 07:42:08 +08:00
João Barbosa
ca4dac48c5 rpc: Add mutex to guard deadlineTimers
Github-Pull: #18814
Rebased-From: a2e6db5c4f
2020-05-15 07:42:07 +08:00
John Newbery
a3fe458a1e [docs] Improve commenting in ProcessGetData()
Github-Pull: #18808
Rebased-From: 9847e205bf
2020-05-15 07:42:07 +08:00
Amiti Uttarwar
011532e380 [test] test that an invalid GETDATA doesn't prevent processing of future messages
Co-Authored-By: John Newbery <john@johnnewbery.com>

Github-Pull: #18808
Rebased-From: 2f032556e0
2020-05-15 07:42:07 +08:00
Amiti Uttarwar
1e73d7248a [net processing] ignore unknown INV types in GETDATA messages
Co-Authored-By: John Newbery <john@johnnewbery.com>

Github-Pull: #18808
Rebased-From: e257cf71c8
2020-05-15 07:42:07 +08:00
Amiti Uttarwar
fb821731eb [net processing] ignore tx GETDATA from blocks-only peers
Co-Authored-By: John Newbery <john@johnnewbery.com>

Github-Pull: #18808
Rebased-From: 047ceac142
2020-05-15 07:42:07 +08:00
João Barbosa
315ae14f3f gui: Fix itemWalletAddress leak when not tree mode
Github-Pull: #18578
Rebased-From: e8123eae40
2020-05-15 07:42:06 +08:00
MarcoFalke
aa7c6858e6 travis: Remove s390x
Github-Pull: #18905
Rebased-From: 8c705ff129
Tree-SHA512: b45e091f00237b96263a967a52ce35bb4782b41a9c69314b30337ca46e9b9a1ed9a9415a30ea5195625e3cc3b231f194a5e097f78cf7159f8090c1e7c826b221
2020-05-14 17:41:16 +02:00
MarcoFalke
7d87ba0e02 travis: Remove valgrind
Github-Pull: #18899
Rebased-From: fa082d0a57
Tree-SHA512: 29b26d3e2cf76fa9762035c2b1444323460c5a6a8d742addd2ec143f2b028d40d5d7992623a41718e550d287f82d4c4781aa82b4cb41504e66567afad7b9215f
2020-05-14 17:39:00 +02:00
Wladimir J. van der Laan
5747c4ca1b Merge #18945: build: Ensure source tarball has leading directory name (0.20)
59d57f6c10 build: Ensure source tarball has leading directory name (Luke Dashjr)

Pull request description:

  In the interest of moving 0.20.0 forward and being able to do rc2, extract and backport the non-controversial part from #18818.: ensure that the source tarball has leading directory name.

ACKs for top commit:
  Sjors:
    tACK 59d57f6c10
  hebasto:
    ACK 59d57f6c10.

Tree-SHA512: 6562f4cd631d2ca3c331a05d028a3c46289a7e146319b8718f96b766f952e3b831d05e249ebcc1b27f5b91a6f318a5fdd86d07b2a80ce792d4b1b032e982ed6a
2020-05-12 16:18:44 +02:00
Luke Dashjr
59d57f6c10 build: Ensure source tarball has leading directory name 2020-05-11 15:09:08 +02:00
Wladimir J. van der Laan
fb5b098598 Merge #18748: [0.20] rc2 Backports
7f7548d822 rpc: Do not advertise dumptxoutset as a way to flush the chainstate (MarcoFalke)
a9ca65bd29 Fix naming of macOS SDK and clarify version (Andrew Chow)
54d2063d1a Do not expose and consider -logthreadnames when it does not work (Hennadii Stepanov)
6986b26346 build: fix ASLR for bitcoin-cli on Windows (fanquake)
1d1e3585fe build: Set libevent minimum version to 2.0.21 (Hennadii Stepanov)
842b13a5f4 Avoid non-trivial global constants in SHA-NI code (Pieter Wuille)
ade4185e63 gitian: Add missing automake package to gitian-win-signer.yml (Andrew Chow)

Pull request description:

  Currently backports the following to the 0.20 branch:

  * #18598 - gitian: Add missing automake package to gitian-win-signer.yml
  * #18702 - build: fix ASLR for bitcoin-cli on Windows
  * #18676 - build: Check libevent minimum version in configure script
  * #18665 - Do not expose and consider -logthreadnames when it does not work
  * #18553 - Avoid non-trivial global constants in SHA-NI code
  * #18589 - Fix naming of macOS SDK and clarify version

ACKs for top commit:
  laanwj:
    ACK 7f7548d822

Tree-SHA512: 2cba748414a440e3fb901940085a7ae059e8b926c9187fbbbdeb7846a32e7374f318cc21e499c911ff803c42aef2c844b04af10b87f9c5a2b3edf6deb03ebb04
2020-05-11 14:58:52 +02:00
MarcoFalke
7f7548d822 rpc: Do not advertise dumptxoutset as a way to flush the chainstate
Github-Pull: #18809
Rebased-From: fac0cf6e55
2020-05-05 07:48:11 +08:00
Andrew Chow
a9ca65bd29 Fix naming of macOS SDK and clarify version
Github-Pull: #18589
Rebased-From: eb37275a6f
2020-04-24 17:24:24 +08:00
Hennadii Stepanov
54d2063d1a Do not expose and consider -logthreadnames when it does not work
Github-Pull: #18665
Rebased-From: b91e4ae0d8
2020-04-23 14:31:32 +08:00
fanquake
6986b26346 build: fix ASLR for bitcoin-cli on Windows
ASLR is not currently working for the bitcoin-cli.exe binary. This is
due to it not having a .reloc section, which is stripped by default by
the mingw-w64 ld we use for gitian builds. A good summary of issues with
ld and mingw-w64 is available in this thread:
https://sourceware.org/bugzilla/show_bug.cgi?id=19011.

All other Windows binaries that we distribute (bitcoind, bitcoin-qt,
bitcoin-wallet, bitcoin-tx and test_bitcoin) do not suffer this issue,
and currently having working ASLR. This is due to them exporting
(inadvertent or not) libsecp256k1 symbols, and, as a result, the .reloc
section is not stripped by ld.

This change is a temporary workaround, also the same one described here:
https://www.kb.cert.org/vuls/id/307144/, that causes main() to be
exported. Exporting a symbol will mean that the .reloc section is not
stripped, and ASLR will function correctly.

Github-Pull: #18702
Rebased-From: 315a4d36f7
2020-04-23 14:30:39 +08:00
Hennadii Stepanov
1d1e3585fe build: Set libevent minimum version to 2.0.21
Github-Pull: #18676
Rebased-From: b68e717967
2020-04-23 14:29:07 +08:00
Pieter Wuille
842b13a5f4 Avoid non-trivial global constants in SHA-NI code
Github-Pull: #18553
Rebased-From: 8508473094
2020-04-23 14:24:10 +08:00
Andrew Chow
ade4185e63 gitian: Add missing automake package to gitian-win-signer.yml
automake is needed to build osslsigncode otherwise autogen.sh fails.

Github-Pull: #18598
Rebased-From: e44aeefaae
2020-04-23 13:32:59 +08:00
Wladimir J. van der Laan
cd1f5bf1db qt: Update translations pre-rc1
Tree-SHA512: 6c695a4a8adc51b72660f012f27548380d44e7b11e10cfa656ef70b0c5412981036a2694f7103821c8eb0148c50b94c69ce5271ed467ae6783a591192a76abdd
v0.20.0rc1
2020-04-10 19:44:47 +02:00
Wladimir J. van der Laan
cd0c998905 doc: Update manpages pre-rc1
Tree-SHA512: 2db55d73d5e4531e8e0699b5572c5f10040054e5955aab67992c9bbd764c910124ab9d09125f69dd25699501a2fc514c274619d1bedf08e0363e21e19241b7f2
2020-04-10 19:41:14 +02:00
Wladimir J. van der Laan
004b0e1b92 build: Bump version to 0.20.0
Bump version to 0.20.0, enable release and set rc1.

Tree-SHA512: aea19b8f7c069dd8798718af392eea89032aa04fa8644a3f115200c662b1dbfb4a5bfca87fe48bb2e77c977b99e1195ccc9752c46ff3f7bf706f2a980b3dd92e
2020-04-10 18:01:50 +02:00
MarcoFalke
a840dab2a5 Merge #18541: rpc: Make verifychain default values static, not depend on global args
fad691cafe rpc: Make verifychain default values static, not depend on global args (MarcoFalke)

Pull request description:

  This fixes several issues:

  * The documentation is not compile-time static and depends on run-time arguments, making it impossible to host it on a static resource like a website or pdf. See also a similar change in the wallet rpc code: #18499
  * The same call (relying on default values) will run different code on different machines, depending on the command line args that were used to start the server. This might lead to hard-to-debug-remote issues.

  This is a small behaviour change, and I will add release notes.

ACKs for top commit:
  theStack:
    ACK fad691cafe
  promag:
    Code review ACK fad691cafe.

Tree-SHA512: 1c7a253ff0ec13a973b10d3777b71c70954ded5805b65a3ab06317327014de4cd0601d71d30c6ce89a581722c150cb5567acc1bd3e0c789cb51bab6ef0dcfc4a
2020-04-10 11:21:57 -04:00
MarcoFalke
3347ca4881 Merge #18526: Remove PID file at the very end
7fcdec0f32 Remove PID file at the very end (Hennadii Stepanov)

Pull request description:

  While reproducing the bug from #18517, I've noticed that the `bitcoind.pid` file has already been removed when the `bitcoind` hangs.

  This PR makes `Shutdown()` keep the `bitcoind.pid` file available until the end.

ACKs for top commit:
  MarcoFalke:
    ACK 7fcdec0f32
  emilengler:
    utACK 7fcdec0f32
  promag:
    Code review ACK 7fcdec0f32.
  theStack:
    Code review ACK 7fcdec0f32

Tree-SHA512: 9732ef34e137dbee70a06d922b316b8ea7b9a1c959cf8861b6940cd789336dc19ee468a4c3a28d95d1458076a48270c676b0ff27fec30cf57eced6ddab0a2a9b
2020-04-10 11:06:27 -04:00
MarcoFalke
29893ec875 Merge #18454: net: Make addr relay mockable, add test
fa1da3d4bf test: Add basic addr relay test (MarcoFalke)
fa1793c1c4 net: Pass connman const when relaying address (MarcoFalke)
fa47a0b003 net: Make addr relay mockable (MarcoFalke)

Pull request description:

  As usual:

  * Switch to std::chrono time to be type-safe and mockable
  * Add basic test that relies on mocktime to add code coverage

ACKs for top commit:
  naumenkogs:
    utACK  fa1da3d
  promag:
    ACK fa1da3d4bf (fabe56e44b6f683e24e37246a7a8851190947cb3 before https://github.com/bitcoin/bitcoin/pull/18454#issuecomment-607866453), fa5bf23d527a450e72c2bf13d013e5393b664ca3 was dropped since last review.

Tree-SHA512: 0552bf8fcbe375baa3cab62acd8c23b2994efa47daff818ad1116d0ffaa0b9e520dc1bca2bbc68369b25584e85e54861fe6fd0968de4f503b95439c099df9bd7
2020-04-10 10:12:46 -04:00
fanquake
2b9a4a1332 Merge #18577: doc: Correct scripted-diff example link
478c11dde3 Correct scripted-diff example link (Yahia Chiheb)

Pull request description:

ACKs for top commit:
  fanquake:
    ACK 478c11dde3

Tree-SHA512: 3bc741a79db9bd7abb17ef11f697b768565ec01303a5823ee6a7d8dfa6e888a99a15e9eda69f97a912abc3fd56a54f698f9a580596511bc9bcf62a6870b273f6
2020-04-10 08:21:50 +08:00
fanquake
d486991aa5 Merge #18295: scripts: add MACHO lazy bindings check to security-check.py
5ca90f8b59 scripts: add MACHO lazy bindings check to security-check.py (fanquake)

Pull request description:

  This is a slightly belated follow up to #17686 and some discussion with Cory. It's not entirely clear if we should make this change due to the way the macOS dynamic loader appears to work. However I'm opening this for some discussion. Also related to #17768.

  #### Issue:
  [`LD64`](https://opensource.apple.com/source/ld64/) doesn't set the [MH_BINDATLOAD](https://opensource.apple.com/source/xnu/xnu-6153.11.26/EXTERNAL_HEADERS/mach-o/loader.h.auto.html) bit in the header of MACHO executables, when building with `-bind_at_load`. This is in contradiction to the [documentation](https://opensource.apple.com/source/ld64/ld64-450.3/doc/man/man1/ld.1.auto.html):
  ```bash
  -bind_at_load
       Sets a bit in the mach header of the resulting binary which tells dyld to
       bind all symbols when the binary is loaded, rather than lazily.
  ```

  The [`ld` in Apples cctools](https://opensource.apple.com/source/cctools/cctools-927.0.2/ld/layout.c.auto.html) does set the bit, however the [cctools-port](https://github.com/tpoechtrager/cctools-port/) that we use for release builds, bundles `LD64`.

  However; even if the linker hasn't set that bit, the dynamic loader ([`dyld`](https://opensource.apple.com/source/dyld/)) doesn't seem to ever check for it, and from what I understand, it looks at a different part of the header when determining whether to lazily load symbols.

  Note that our release binaries are currently working as expected, and no lazy loading occurs.

  #### Example:

  Using a small program, we can observe the behaviour of the dynamic loader.

  Conducted using:
  ```bash
  clang++ --version
  Apple clang version 11.0.0 (clang-1100.0.33.17)
  Target: x86_64-apple-darwin18.7.0

  ld -v
  @(#)PROGRAM:ld  PROJECT:ld64-530
  BUILD 18:57:17 Dec 13 2019
  LTO support using: LLVM version 11.0.0, (clang-1100.0.33.17) (static support for 23, runtime is 23)
  TAPI support using: Apple TAPI version 11.0.0 (tapi-1100.0.11)
  ```

  ```cpp
  #include <iostream>
  int main() {
  	std::cout << "Hello World!\n";
  	return 0;
  }
  ```

  Compile and check the MACHO header:
  ```bash
  clang++ test.cpp -o test
  otool -vh test
  ...
  Mach header
        magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
  MH_MAGIC_64  X86_64        ALL LIB64     EXECUTE    16       1424   NOUNDEFS DYLDLINK TWOLEVEL WEAK_DEFINES BINDS_TO_WEAK PIE

  # Run and dump dynamic loader bindings:
  DYLD_PRINT_BINDINGS=1 DYLD_PRINT_TO_FILE=no_bind.txt ./test
  Hello World!
  ```

  Recompile with `-bind_at_load`. Note still no `BINDATLOAD` flag:
  ```bash
  clang++ test.cpp -o test -Wl,-bind_at_load
  otool -vh test
  Mach header
        magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
  MH_MAGIC_64  X86_64        ALL LIB64     EXECUTE    16       1424   NOUNDEFS DYLDLINK TWOLEVEL WEAK_DEFINES BINDS_TO_WEAK PIE
  ...
  DYLD_PRINT_BINDINGS=1 DYLD_PRINT_TO_FILE=bind.txt ./test
  Hello World!
  ```

  If we diff the outputs, you can see that `dyld` doesn't perform any lazy bindings when the binary is compiled with `-bind_at_load`, even if the `BINDATLOAD` flag is not set:
  ```diff
  @@ -1,11 +1,27 @@
  +dyld: bind: test:0x103EDF030 = libc++.1.dylib:__ZNKSt3__16locale9use_facetERNS0_2idE, *0x103EDF030 = 0x7FFF70C9FA58
  +dyld: bind: test:0x103EDF038 = libc++.1.dylib:__ZNKSt3__18ios_base6getlocEv, *0x103EDF038 = 0x7FFF70CA12C2
  +dyld: bind: test:0x103EDF068 = libc++.1.dylib:__ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE6sentryC1ERS3_, *0x103EDF068 = 0x7FFF70CA12B6
  +dyld: bind: test:0x103EDF070 = libc++.1.dylib:__ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE6sentryD1Ev, *0x103EDF070 = 0x7FFF70CA1528
  +dyld: bind: test:0x103EDF080 = libc++.1.dylib:__ZNSt3__16localeD1Ev, *0x103EDF080 = 0x7FFF70C9FAE6
  <trim>
  -dyld: lazy bind: test:0x10D4AC0C8 = libsystem_platform.dylib:_strlen, *0x10D4AC0C8 = 0x7FFF73C5C6E0
  -dyld: lazy bind: test:0x10D4AC068 = libc++.1.dylib:__ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE6sentryC1ERS3_, *0x10D4AC068 = 0x7FFF70CA12B6
  -dyld: lazy bind: test:0x10D4AC038 = libc++.1.dylib:__ZNKSt3__18ios_base6getlocEv, *0x10D4AC038 = 0x7FFF70CA12C2
  -dyld: lazy bind: test:0x10D4AC030 = libc++.1.dylib:__ZNKSt3__16locale9use_facetERNS0_2idE, *0x10D4AC030 = 0x7FFF70C9FA58
  -dyld: lazy bind: test:0x10D4AC080 = libc++.1.dylib:__ZNSt3__16localeD1Ev, *0x10D4AC080 = 0x7FFF70C9FAE6
  -dyld: lazy bind: test:0x10D4AC070 = libc++.1.dylib:__ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE6sentryD1Ev, *0x10D4AC070 = 0x7FFF70CA1528
  ```

  Note: `dyld` also has a `DYLD_BIND_AT_LAUNCH=1` environment variable, that when set, will force any lazy bindings to be non-lazy:
  ```bash
  dyld: forced lazy bind: test:0x10BEC8068 = libc++.1.dylib:__ZNSt3__113basic_ostream
  ```

  #### Thoughts:
  After looking at the dyld source, I can't find any checks for `MH_BINDATLOAD`. You can see the flags it does check for, such as MH_PIE or MH_BIND_TO_WEAK [here](https://opensource.apple.com/source/dyld/dyld-732.8/src/ImageLoaderMachO.cpp.auto.html).

  It seems that the lazy binding of any symbols depends on whether or not [lazy_bind_size](https://opensource.apple.com/source/xnu/xnu-6153.11.26/EXTERNAL_HEADERS/mach-o/loader.h.auto.html) from the `LC_DYLD_INFO_ONLY` load command is > 0. Which was mentioned in [#17686](https://github.com/bitcoin/bitcoin/pull/17686#issue-350216254).

  #### Changes:
  This PR is one of [Corys commits](7b6ba26178), that I've rebased and modified to make build. I've also included an addition to the `security-check.py` script to check for the flag.

  However, given the above, I'm not entirely sure this patch is the correct approach. If the linker no-longer inserts it, and the dynamic loader doesn't look for it, there might be little benefit to setting it. Or, maybe this is an oversight from Apple and needs some upstream discussion. Looking for some thoughts / Concept ACK/NACK.

  One alternate approach we could take is to drop the patch and modify security-check.py to look for `lazy_bind_size` == 0 in the `LC_DYLD_INFO_ONLY` load command, using `otool -l`.

ACKs for top commit:
  theuni:
    ACK 5ca90f8b59

Tree-SHA512: 444022ea9d19ed74dd06dc2ab3857a9c23fbc2f6475364e8552d761b712d684b3a7114d144f20de42328d1a99403b48667ba96885121392affb2e05b834b6e1c
2020-04-10 07:42:20 +08:00
MarcoFalke
405713d00f Merge #18529: Add fuzzer version of randomized prevector test
b1d24d1d03 Reorder the test instructions by number (Pieter Wuille)
c2ccadc26a Merge and generalize case 3 and case 6 (Pieter Wuille)
402ad5aaca Only run sanity check once at the end (Pieter Wuille)
eda8309bfc Assert immediately rather than caching failure (Pieter Wuille)
55608455cb Make a fuzzer-based copy of the prevector randomized test (Pieter Wuille)

Pull request description:

  The current prevector test effectively randomly generates a number of operations to perform on a prevector and a normal vector, and checks consistency between the two.

  By converting this into a fuzzer the operations can be targetted rather than random.

ACKs for top commit:
  MarcoFalke:
    ACK b1d24d1d03 🍬

Tree-SHA512: 2b5c62abcd5fee94f42db03400531484d98c59e7f4308e0e683c61aabcd9ce42f85c5d058d2d5e7f8221124f71d2112b6a5f3c80e5d0fdae265a70647747e92f
2020-04-09 15:00:57 -04:00