gui icon indicating copy to clipboard operation
gui copied to clipboard

SplashScreen segfault when wallet cannot be loaded

Open achow101 opened this issue 3 years ago • 1 comments

Asa reported in https://github.com/bitcoin/bitcoin/issues/25146, when configured to load with a wallet that cannot be loaded, there is a segfault during the shutdown procedure.

I have been able to trace this segfault to the SplashScreen where the it appears that it is executing an interfaces::Handler that is accessing an object that has already been deleted. This seems to be related to this comment about cleaning up WalletController. Deleting m_splash at the same place appears to resolve the problem. However I am not sure if that is a viable long term fix.

Note that the segfault does not always occur for me. I believe this is due to deletion order which is not always the same. So sometimes m_splash is deleted before contexts are deleted, and sometimes after those contexts are deleted. I believe the segfault is due to accessing those contexts after deletion.

achow101 avatar May 20 '22 19:05 achow101

I believe the segfault is due to accessing those contexts after deletion.

I can confirm that segfault is due the context object has been deleted before the context.wallet_load_fns.erase(it); call: https://github.com/bitcoin-core/gui/blob/640eb772e55671c5dab29843cebe42ec35cb703f/src/wallet/wallet.cpp#L161-L166

hebasto avatar May 22 '22 14:05 hebasto