Steps to reproduce:
- Set time to next day
- Start IBD
- Wait
- GUI freezes
Cannot reproduce this issue on master (9217f9fe7351d9c36803456f88ae561e23f17ac9):
I had tried experimenting with this. It’s difficult to reproduce this because it’s intermittent. Sometimes GUI will freeze on a machine, will work fine next time you try or on other machine. So I assumed it’s not an issue with Bitcoin Core itself.
I had tried on Windows as host, Windows in VM, Ubuntu as host and Ubuntu in VM. Bitcoin Core v0.21.0
… it’s intermittent.
If you were lucky to reproduce it, maybe you got a backtrace from a debugger?
I didn’t try today. It was something that happened with me because VM was using date from host and my CMOS battery was dead so host machine was using some crazy date from 2093.
Will share logs if I can reproduce it on my desktop.
The BitcoinGUI::subscribeToCoreSignals
, that is called from the BitcoinGUI
ctor, uses the this
pointer.
Would it be, that https://github.com/bitcoin/bitcoin/blob/9217f9fe7351d9c36803456f88ae561e23f17ac9/src/timedata.cpp#L95
is called before BitcoinGUI
object is fully initialized?
This seems to fix it…
The change of the nTimeOffset data type from int to int64_t in
seems to be the root of the issue…
Patch/FIx:
0diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp
1index d6706fd009..877de36faf 100644
2--- a/src/qt/guiutil.cpp
3+++ b/src/qt/guiutil.cpp
4@@ -750,7 +750,7 @@ QString formatPingTime(std::chrono::microseconds ping_time)
5
6 QString formatTimeOffset(int64_t nTimeOffset)
7 {
8- return QObject::tr("%1 s").arg(QString::number((int)nTimeOffset, 10));
9+ return QObject::tr("%1 s").arg(QString::number(nTimeOffset, 10));
10 }
11
12 QString formatNiceTimeOffset(qint64 secs)
https://github.com/bitcoin/bitcoin/compare/master...RandyMcMillan:1647799609-1647799494-master-18953
The argument used to be an int
QString formatDurationStr(int secs);
NOTE:
As mentioned above +/- one day triggers a similar condition.
One difference that I have noticed is that when the time is spoofed negative - all nodes that connect prior to the bug - don’t begin syncing with the node - besides the initial handshake.
0diff --git a/src/util/time.cpp b/src/util/time.cpp
1index f7712f0dc8..6872a6871e 100644
2--- a/src/util/time.cpp
3+++ b/src/util/time.cpp
4@@ -30,7 +30,7 @@ int64_t GetTime()
5
6 time_t now = time(nullptr);
7 assert(now > 0);
8- return now;
9+ return now - 24*60*60;
10 }
11
12 bool ChronoSanityCheck()
On the contrary - when the time is spoofed in the positive - the first node will begin to sync (send block data).
0diff --git a/src/util/time.cpp b/src/util/time.cpp
1index f7712f0dc8..6872a6871e 100644
2--- a/src/util/time.cpp
3+++ b/src/util/time.cpp
4@@ -30,7 +30,7 @@ int64_t GetTime()
5
6 time_t now = time(nullptr);
7 assert(now > 0);
8- return now;
9+ return now + 24*60*60;
10 }
11
12 bool ChronoSanityCheck()
Tweaking the -maxtimeadjustment setting seems to have an effect that I haven’t fully looked into… more testing with the patches above may offer some more insight…
0$ make appbundle && ./Bitcoin-Qt.app/Contents/MacOS/Bitcoin-Qt -signet -maxtimeadjustment 10000000