Skip to content

Conversation

@sipa
Copy link
Member

@sipa sipa commented Apr 7, 2020

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.

@fanquake
Copy link
Member

fanquake commented Apr 7, 2020

I take it this resolves this comment?

@sipa
Copy link
Member Author

sipa commented Apr 7, 2020

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

@promag
Copy link
Contributor

promag commented Apr 7, 2020

This change is now covered in #18471.

ryanofsky added a commit to ryanofsky/bitcoin that referenced this pull request Apr 7, 2020
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 bitcoin#18524 and is
fixed by bitcoin#18551
@ryanofsky
Copy link
Contributor

Code review ACK c182fd5

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

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

@ryanofsky
Copy link
Contributor

ryanofsky commented Apr 7, 2020

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

@promag
Copy link
Contributor

promag commented Apr 7, 2020

Code review ACK c182fd5.

sipa and others added 2 commits April 7, 2020 12:53
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.
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 bitcoin#18524 and is
fixed by bitcoin#18551
@sipa sipa force-pushed the 202004_fix_validation_notify_clear branch from c182fd5 to 2276339 Compare April 7, 2020 19:57
@sipa
Copy link
Member Author

sipa commented Apr 7, 2020

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

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@jonasschnelli
Copy link
Contributor

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

@maflcko
Copy link
Member

maflcko commented Apr 8, 2020

ACK 2276339 🎎

Show signature and timestamp

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 -

@maflcko maflcko merged commit 1f70185 into bitcoin:master Apr 8, 2020
@maflcko
Copy link
Member

maflcko commented Apr 8, 2020

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

@maflcko
Copy link
Member

maflcko commented Apr 8, 2020

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

@ryanofsky
Copy link
Contributor

ryanofsky commented Apr 8, 2020

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

@ryanofsky
Copy link
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:
 // https://github.com/bitcoin/bitcoin/pull/18551
 BOOST_AUTO_TEST_CASE(unregister_all_during_call)
 {
+#ifdef WIN32
+    return;
+#endif
     bool destroyed = false;
 
     CScheduler scheduler;

@maflcko
Copy link
Member

maflcko commented Apr 8, 2020

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

@fanquake
Copy link
Member

fanquake commented Apr 8, 2020

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

@ryanofsky
Copy link
Contributor

I think I see the problem. The failing assert is in RegisterBackgroundSignalScheduler

assert(!m_internals);

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

ryanofsky added a commit to ryanofsky/bitcoin that referenced this pull request Apr 8, 2020
Use TestingSetup fixture to fix unregister_all_during_call test not calling
UnregisterBackgroundSignalScheduler, which could trigger an assert in
RegisterBackgroundSignalScheduler when called in later tests

Failure reported by fanquake <[email protected]>
bitcoin#18551 (comment)
@ryanofsky
Copy link
Contributor

#18563 should probably fix the test failures

maflcko pushed a commit to maflcko/bitcoin-core that referenced this pull request Apr 8, 2020
13d2a33 Fix unregister_all_during_call cleanup (Russell Yanofsky)

Pull request description:

  Use `TestingSetup` fixture to fix `unregister_all_during_call` test not calling `UnregisterBackgroundSignalScheduler`, which could trigger an assert in `RegisterBackgroundSignalScheduler` when called in later tests

  Failure reported by fanquake bitcoin#18551 (comment)

ACKs for top commit:
  MarcoFalke:
    ACK 13d2a33 if appveyor unit tests pass

Tree-SHA512: d2ec8ff14c54d97903af50031abfac1f38ec1c3aabc90371cfd5b79481fa69d3d77f339bfdf7d2178fd85e83402f72eda7cf4d339e5bbfa7e6e1a68836643b93
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Apr 8, 2020
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 bitcoin#18524 and is
fixed by bitcoin#18551
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Apr 8, 2020
Use TestingSetup fixture to fix unregister_all_during_call test not calling
UnregisterBackgroundSignalScheduler, which could trigger an assert in
RegisterBackgroundSignalScheduler when called in later tests

Failure reported by fanquake <[email protected]>
bitcoin#18551 (comment)
HashUnlimited pushed a commit to HashUnlimited/chaincoin that referenced this pull request Apr 17, 2020
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 bitcoin#18524 and is
fixed by bitcoin#18551
HashUnlimited pushed a commit to HashUnlimited/chaincoin that referenced this pull request Apr 17, 2020
Use TestingSetup fixture to fix unregister_all_during_call test not calling
UnregisterBackgroundSignalScheduler, which could trigger an assert in
RegisterBackgroundSignalScheduler when called in later tests

Failure reported by fanquake <[email protected]>
bitcoin#18551 (comment)
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jun 20, 2020
Summary:
2276339a176f83ffe8ceefb3e41ecca8601aa13b Add test for UnregisterAllValidationInterfaces bug (Russell Yanofsky)
3c61abbbc847d725f30d169278d84655571407c1 Do not clear validationinterface entries being executed (Pieter Wuille)

Pull request description:

  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.

ACKs for top commit:
  jonasschnelli:
    utACK 2276339a176f83ffe8ceefb3e41ecca8601aa13b - reviewed code and test (thanks @ryanofsky for adding the test).
  MarcoFalke:
    ACK 2276339a176f83ffe8ceefb3e41ecca8601aa13b 🎎
  ryanofsky:
    Code review ACK 2276339a176f83ffe8ceefb3e41ecca8601aa13b. No change to bugfix, just rebased and new test commit added since last review

Tree-SHA512: c1d68e7c681a45c6cadc84e407c2266bcb4b12d34264e1232a61c4eadb74b551231c5a3b1d041de39f507aef4dfa7d4589b8bfe1833f069c739c6270d2a05dbe

Backport of Core [[bitcoin/bitcoin#18551 | PR18551]]

Depends on D6653

Test Plan: `ninja check`

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: deadalnix, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D6654
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jun 20, 2020
Summary:
13d2a33537a403ac47a989be92109d3214375b6a Fix unregister_all_during_call cleanup (Russell Yanofsky)

Pull request description:

  Use `TestingSetup` fixture to fix `unregister_all_during_call` test not calling `UnregisterBackgroundSignalScheduler`, which could trigger an assert in `RegisterBackgroundSignalScheduler` when called in later tests

  Failure reported by fanquake bitcoin/bitcoin#18551 (comment)

ACKs for top commit:
  MarcoFalke:
    ACK 13d2a33537a403ac47a989be92109d3214375b6a if appveyor unit tests pass

Tree-SHA512: d2ec8ff14c54d97903af50031abfac1f38ec1c3aabc90371cfd5b79481fa69d3d77f339bfdf7d2178fd85e83402f72eda7cf4d339e5bbfa7e6e1a68836643b93

Backport of Core [[bitcoin/bitcoin#18563 | PR18563]]

Depends on D6654

Test Plan: `ninja check`

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D6655
janus pushed a commit to janus/bitgesell that referenced this pull request Nov 5, 2020
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 bitcoin/bitcoin#18524 and is
fixed by bitcoin/bitcoin#18551
janus pushed a commit to janus/bitgesell that referenced this pull request Nov 8, 2020
Use TestingSetup fixture to fix unregister_all_during_call test not calling
UnregisterBackgroundSignalScheduler, which could trigger an assert in
RegisterBackgroundSignalScheduler when called in later tests

Failure reported by fanquake <[email protected]>
bitcoin/bitcoin#18551 (comment)
backpacker69 pushed a commit to peercoin/peercoin that referenced this pull request Mar 28, 2021
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 bitcoin/bitcoin#18524 and is
fixed by bitcoin/bitcoin#18551
backpacker69 pushed a commit to peercoin/peercoin that referenced this pull request Mar 28, 2021
Use TestingSetup fixture to fix unregister_all_during_call test not calling
UnregisterBackgroundSignalScheduler, which could trigger an assert in
RegisterBackgroundSignalScheduler when called in later tests

Failure reported by fanquake <[email protected]>
bitcoin/bitcoin#18551 (comment)
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants