Do not clear validationinterface entries being executed #18551

pull sipa wants to merge 2 commits into bitcoin:master from sipa:202004_fix_validation_notify_clear changing 3 files +66 −2
  1. sipa commented at 2:17 AM on April 7, 2020: member

    The previous code for MainSignalsInstance::Clear would decrement the reference count of every interface, including ones that were already Unregister()ed but still being executed.

    This fixes the issue pointed out here: https://github.com/bitcoin/bitcoin/pull/18524/files#r404395685 . It's not currently observable.

  2. fanquake added the label Validation on Apr 7, 2020
  3. fanquake commented at 2:19 AM on April 7, 2020: member

    I take it this resolves this comment?

  4. sipa cross-referenced this on Apr 7, 2020 from issue refactor: drop boost::signals2 in validationinterface by ryanofsky
  5. sipa commented at 2:20 AM on April 7, 2020: member

    @fanquake You're too fast. I was just looking to add a link where I made that comment.

  6. fanquake requested review from ryanofsky on Apr 7, 2020
  7. promag cross-referenced this on Apr 7, 2020 from issue qa: Test shared validation interface by promag
  8. promag commented at 9:45 AM on April 7, 2020: member

    This change is now covered in #18471.

  9. ryanofsky referenced this in commit 4ba1627fb9 on Apr 7, 2020
  10. ryanofsky commented at 12:17 PM on April 7, 2020: contributor

    Code review ACK c182fd517db2337f61b0038ca929fcfd01f18f07

    I wrote a test for the bug that fails without the fix and passes with it: 4ba1627fb99ea46836e0d73ad1682b4b184124be (branch)

    Feel free to use the test here and squash into the fix commit.

  11. ryanofsky approved
  12. ryanofsky commented at 12:30 PM on April 7, 2020: contributor

    Note: This PR fixes a bug in an internal function. The fix doesn't affect behavior of bitcoind, the gui, or any utilities because the function isn't currently called in a way that would trigger the bug

  13. promag commented at 6:23 PM on April 7, 2020: member

    Code review ACK c182fd517db2337f61b0038ca929fcfd01f18f07.

  14. Do not clear validationinterface entries being executed
    The previous code for MainSignalsInstance::Clear would decrement the reference
    count of every interface, including ones that were already Unregister()ed but
    still being executed.
    3c61abbbc8
  15. Add test for UnregisterAllValidationInterfaces bug
    Bug in MainSignalsInstance::Clear could cause validation interface callbacks to
    be deleted during execution if UnregisterAllValidationInterfaces was called
    more than once.
    
    Bug was introduced in https://github.com/bitcoin/bitcoin/pull/18524 and is
    fixed by https://github.com/bitcoin/bitcoin/pull/18551
    2276339a17
  16. sipa force-pushed on Apr 7, 2020
  17. sipa commented at 7:58 PM on April 7, 2020: member

    @ryanofsky Cherry-picked. Also updated the PR description to say it's not currently observable.

  18. ryanofsky approved
  19. ryanofsky commented at 8:04 PM on April 7, 2020: contributor

    Code review ACK 2276339a176f83ffe8ceefb3e41ecca8601aa13b. No change to bugfix, just rebased and new test commit added since last review

  20. jonasschnelli commented at 10:10 AM on April 8, 2020: contributor

    utACK 2276339a176f83ffe8ceefb3e41ecca8601aa13b - reviewed code and test (thanks @ryanofsky for adding the test).

  21. MarcoFalke commented at 12:42 PM on April 8, 2020: member

    ACK 2276339a176f83ffe8ceefb3e41ecca8601aa13b 🎎

    <details><summary>Show signature and timestamp</summary>

    Signature:

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA512
    
    ACK 2276339a176f83ffe8ceefb3e41ecca8601aa13b 🎎
    -----BEGIN PGP SIGNATURE-----
    
    iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
    pUh20Qv+N8PfCJlrF51u9zKcnkK1GBJis/ghaoibar1FJ1i1HSbPRRL+eKYVv0Sy
    1EtNyAVItG33UTdTRWO5ektfVHDweRO3XZZwknk0Jo/iUo+dLMhXoEvu4/izJ09V
    3K/ae/hZDnX5rARkOIW00NYtFdm3ynWtPXG6g5p5U9RJeZ31StmJoXp8FESDRhsl
    qx5vJSEhV7hG+oUl6seSJLFdMZ3F8E6/OPg7kBMCRPKJI9/CrKrbUMLUbiV8LZy3
    RJFrcCBWWa0Nw5T+mxoHl83iHJZKnPK5cKLzNYt1IkBC826KJKE1sN5lPz6zReug
    cMkr3ycS8TlXiNRo8fsQNaCV7xj0qAVcXgqqJurOyA0DadMSaddvj9NMD93BZDI+
    xO6fY8bVY6c4yTY+le0Ap0LhTdtvK4w//ld8K2lPMEVuhH3m5e8vjJHW87VWQQiG
    xL78hivW6rda/QqCKs4Ad5CupVLrCjVpDcCu2dZihoXmuqpXmH9Dekz2vdbR4/Il
    nKUooeqh
    =fz/C
    -----END PGP SIGNATURE-----
    

    Timestamp of file with hash 85ad0a848e9b8fccb5f691da9f517f86522c78158bd9a4bd80a6403b8f07cf8b -

    </details>

  22. MarcoFalke merged this on Apr 8, 2020
  23. MarcoFalke closed this on Apr 8, 2020

  24. MarcoFalke commented at 12:45 PM on April 8, 2020: member

    cc @sipsorcery (or anyone else on windows) any idea why this fails appveyor?

  25. ryanofsky commented at 1:07 PM on April 8, 2020: contributor

    cc @sipsorcery (or anyone else on windows) any idea why this fails appveyor?

    Appveyor links

    https://ci.appveyor.com/project/DrahtBot/bitcoin/builds/32000822 (passed) https://ci.appveyor.com/project/DrahtBot/bitcoin/builds/32021955 (failed) https://ci.appveyor.com/project/DrahtBot/bitcoin/builds/32023789 (failed) https://ci.appveyor.com/project/DrahtBot/bitcoin/builds/32039241 (pending)

    I think this is the error message

    src\test_bitcoin.exe -k stdout -e stdout 2> NUL
    Command exited with code -1073740791
    
  26. MarcoFalke commented at 1:10 PM on April 8, 2020: member

    Yeah, stuff like this #16976 makes it hard to debug

  27. ryanofsky commented at 1:16 PM on April 8, 2020: contributor

    The PR was rebased between the passing build and failing build https://github.com/bitcoin/bitcoin/compare/c182fd51..2276339a, but I'd guess probably the new unregister_all_during_call unit test is crashing and causing the failure

    EDIT: Actually that diff link is misleading because appveyor builds branches merged with master. Still it seems pretty likely the new unregister_all_during_call test is causing this

  28. ryanofsky commented at 1:29 PM on April 8, 2020: contributor

    Could disable this if appveyor failures cause problems for other PRs:

    --- a/src/test/validationinterface_tests.cpp
    +++ b/src/test/validationinterface_tests.cpp
    @@ -42,6 +42,9 @@ public:
     // [#18551](/github-metadata-backup-bitcoin-bitcoin/18551/)
     BOOST_AUTO_TEST_CASE(unregister_all_during_call)
     {
    +#ifdef WIN32
    +    return;
    +#endif
         bool destroyed = false;
     
         CScheduler scheduler;
    
  29. MarcoFalke commented at 1:34 PM on April 8, 2020: member

    appveyor was already failing on pretty much every pull, so I think this is not an issue

  30. fanquake commented at 1:54 PM on April 8, 2020: member

    The tests are now failing, and it was caused by this pull. Maybe we can disable as @ryanofsky suggested. I haven't been able to investigate further:

    Running 370 test cases...
    Assertion failed!
    
    Program: C:\workspace\bitcoin\bin\test_bitcoin.exe
    File: validationinterface.cpp, Line 93
    
    Expression: !m_internals
    
  31. ryanofsky commented at 2:06 PM on April 8, 2020: contributor

    I think I see the problem. The failing assert is in RegisterBackgroundSignalScheduler https://github.com/bitcoin/bitcoin/blob/1f70185a809362117a8158e386fdead85728794f/src/validationinterface.cpp#L93

    and is probably failing because the test isn't calling UnregisterBackgroundSignalScheduler to clean up after itself

  32. ryanofsky referenced this in commit 13d2a33537 on Apr 8, 2020
  33. ryanofsky cross-referenced this on Apr 8, 2020 from issue test: Fix unregister_all_during_call cleanup by ryanofsky
  34. ryanofsky commented at 2:20 PM on April 8, 2020: contributor

    #18563 should probably fix the test failures

  35. MarcoFalke referenced this in commit 2392566284 on Apr 8, 2020
  36. sidhujag referenced this in commit 93082b3112 on Apr 8, 2020
  37. sidhujag referenced this in commit a032db8672 on Apr 8, 2020
  38. glozow referenced this in commit d7bce8a0d7 on Apr 10, 2020
  39. glozow referenced this in commit 9a83c0971e on Apr 10, 2020
  40. HashUnlimited referenced this in commit c33572b2d3 on Apr 17, 2020
  41. HashUnlimited referenced this in commit ab68ba7273 on Apr 17, 2020
  42. deadalnix referenced this in commit 1064bda698 on Jun 20, 2020
  43. deadalnix referenced this in commit 6f74431345 on Jun 20, 2020
  44. metalicjames referenced this in commit 09af10dec5 on Aug 5, 2020
  45. janus referenced this in commit d90950d5f8 on Nov 5, 2020
  46. janus referenced this in commit c5ded8c219 on Nov 8, 2020
  47. backpacker69 referenced this in commit aa49101317 on Mar 28, 2021
  48. backpacker69 referenced this in commit 1a28b719bb on Mar 28, 2021
  49. bitcoin locked this on Feb 15, 2022

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-05-19 06:54 UTC