The dcd6eeb64adb2b532f5003cbb86ba65b3c08a87b commit (bitcoin/bitcoin#23288) introduced an intermittent failure in the psbt_wallet_tests/psbt_updater_test unit test. See bitcoin/bitcoin#23368.
The test failure can be easily made reproducible with the following patch:
--- a/src/scheduler.cpp
+++ b/src/scheduler.cpp
@@ -57,6 +57,8 @@ void CScheduler::serviceQueue()
Function f = taskQueue.begin()->second;
taskQueue.erase(taskQueue.begin());
+ UninterruptibleSleep(100ms);
+
{
// Unlock before calling f, so it can reschedule itself or another task
// without deadlocking:
This PR implements an idea which was mentioned in the comment:
Yes, as I said before this looks like a race where the wallet is deleted before stopping the scheduler: #23368 (comment)
IIRC, the order should be:
stop scheduler
delete wallet
delete scheduler
The second commit introduces a refactoring with no behavior change.
Fixes bitcoin/bitcoin#23368.