dashpay / dash

Dash - Reinventing Cryptocurrency
https://www.dash.org
MIT License
1.49k stars 1.2k forks source link

fix: missing lock cs_wallet in rpc/evo #6002

Closed knst closed 4 months ago

knst commented 4 months ago

Issue being fixed or feature implemented

Changing order of locking cs_main and cs_wallet to prevent a deadlock.

There's call protx_list -> BuildDMNListEntry -> CheckWalletOwnsScript:

return WITH_LOCK(pwallet->cs_wallet, return pwallet->IsMine(script)) == isminetype::ISMINE_SPENDABLE; 

It can cause a deadlock due to wrong order of locks (cs_wallet supposed to be blocked in prior of cs_main)

What was done?

This PR adds and extra lock of cs_wallet and reduce scope of cs_main for a bit

How Has This Been Tested?

Deadlock warning is reproduced with this PR: https://github.com/dashpay/dash/pull/6003

Breaking Changes

N/A

Checklist: