Commit 2cb720a
Acquire cs_main lock before cs_wallet during wallet initialization
CWallet::MarkConflicted may acquire the cs_main lock after
CWalletDB::LoadWallet acquires the cs_wallet lock during wallet initialization.
(CWalletDB::LoadWallet calls ReadKeyValue which calls CWallet::LoadToWallet
which calls CWallet::MarkConflicted). This is the opposite order that cs_main
and cs_wallet locks are acquired in the rest of the code, and so leads to
POTENTIAL DEADLOCK DETECTED errors if bitcoin is built with -DDEBUG_LOCKORDER.
This commit changes CWallet::LoadWallet (which calls CWalletDB::LoadWallet) to
acquire both locks in the standard order. It also fixes some tests that were
acquiring wallet and main locks out of order and failed with the new locking in
CWallet::LoadWallet.
Error was reported by Luke Dashjr <[email protected]> in
https://botbot.me/freenode/bitcoin-core-dev/msg/90244330/
Github-Pull: #11126
Rebased-From: de9a1db1 parent b278a43 commit 2cb720a
2 files changed
+12
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
364 | 364 | | |
365 | 365 | | |
366 | 366 | | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
367 | 373 | | |
368 | 374 | | |
369 | 375 | | |
| |||
379 | 385 | | |
380 | 386 | | |
381 | 387 | | |
382 | | - | |
383 | | - | |
| 388 | + | |
384 | 389 | | |
385 | 390 | | |
386 | 391 | | |
| |||
393 | 398 | | |
394 | 399 | | |
395 | 400 | | |
396 | | - | |
397 | | - | |
| 401 | + | |
398 | 402 | | |
399 | 403 | | |
400 | 404 | | |
| |||
599 | 603 | | |
600 | 604 | | |
601 | 605 | | |
602 | | - | |
603 | | - | |
| 606 | + | |
604 | 607 | | |
605 | 608 | | |
606 | 609 | | |
| |||
635 | 638 | | |
636 | 639 | | |
637 | 640 | | |
638 | | - | |
| 641 | + | |
639 | 642 | | |
640 | 643 | | |
641 | 644 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3101 | 3101 | | |
3102 | 3102 | | |
3103 | 3103 | | |
| 3104 | + | |
| 3105 | + | |
3104 | 3106 | | |
3105 | 3107 | | |
3106 | 3108 | | |
3107 | 3109 | | |
3108 | 3110 | | |
3109 | 3111 | | |
3110 | | - | |
3111 | 3112 | | |
3112 | 3113 | | |
3113 | 3114 | | |
| |||
0 commit comments