bitcoin icon indicating copy to clipboard operation
bitcoin copied to clipboard

Likely Deadlock cs_setpwalletRegistered

Open pstratem opened this issue 13 years ago • 7 comments

2013-09-01 09:22:23 POTENTIAL DEADLOCK DETECTED 2013-09-01 09:22:23 Previous lock order was: 2013-09-01 09:22:23 (1) cs_wallet wallet.cpp:774 2013-09-01 09:22:23 mempool.cs main.cpp:1114 2013-09-01 09:22:23 (2) cs_setpwalletRegistered main.cpp:129 2013-09-01 09:22:23 Current lock order is: 2013-09-01 09:22:23 pnode->cs_vRecvMsg net.cpp:1518 2013-09-01 09:22:23 cs_main main.cpp:4062 2013-09-01 09:22:23 (2) cs_setpwalletRegistered main.cpp:161 2013-09-01 09:22:23 (1) cs_wallet wallet.h:310 2013-09-01 09:22:23 LOCKCONTENTION: cs_setpwalletRegistered 2013-09-01 09:22:23 Locker: main.cpp:129

This is likely caused by this commit https://github.com/bitcoin/bitcoin/commit/e5cefb9b

pstratem avatar Sep 01 '13 09:09 pstratem

This should at least be investigated before 0.9.0.

sipa avatar Sep 01 '13 09:09 sipa

@CodeShark Can you take a look please.

Diapolo avatar Sep 19 '13 10:09 Diapolo

A possible deadlock is a thing we should fix ASAP, can any core dev take a look?

Diapolo avatar Oct 04 '13 08:10 Diapolo

I had actually replaced these locks with shared locks that shouldn't have this issue - but apparently they caused pulltester to choke so they were removed. The only place where locking is necessary is when modifying the setpwalletRegistered structure itself (ie inserting or deleting).

CodeShark avatar Oct 09 '13 20:10 CodeShark

Did anyone ever figure out why the boost::shared_lock solution didn't work? I had tested it on my own system and didn't have any problems with it.

CodeShark avatar Oct 09 '13 21:10 CodeShark

@CodeShark Could be because of old compiler/build environment and old Boost version used!?

Diapolo avatar Oct 10 '13 07:10 Diapolo

I believe the solution here is to use boost::signals2 to register the wallet callbacks; signals2 is actually specifically designed to be thread-safe, while being concurrently modifiable.

sipa avatar Oct 18 '13 20:10 sipa