qt: Potential deadlock in peertablemodel #4296

issue laanwj opened this issue on June 6, 2014
  1. laanwj commented at 5:59 AM on June 6, 2014: member

    When compiling with -DDEBUG_LOCKORDER:

    2014-06-06 05:56:32 POTENTIAL DEADLOCK DETECTED
    2014-06-06 05:56:32 Previous lock order was:
    2014-06-06 05:56:32  (1) cs_main  qt/clientmodel.cpp:102
    2014-06-06 05:56:32  (2) cs_vNodes  qt/clientmodel.cpp:48
    2014-06-06 05:56:32 Current lock order is:
    2014-06-06 05:56:32  (2) cs_vNodes  qt/peertablemodel.cpp:52
    2014-06-06 05:56:32  (1) cs_main  qt/peertablemodel.cpp:73
    2014-06-06 05:56:32  (1) cs_main  main.cpp:316
    

    @ashleyholman

  2. laanwj renamed this:
    Potential deadlock in peertablemodel
    qt: Potential deadlock in peertablemodel
    on Jun 6, 2014
  3. ashleyholman commented at 6:08 AM on June 6, 2014: contributor

    My code is not holding both locks at the same time. It should be releasing cs_vNodes and then acquiring cs_main, so my understanding is that there shouldn't be a potential for deadlock?

    To prevent that warning I could lock cs_main and then acquire cs_vNodes, but I'd need to hold both at the same time to do it in that order, because the cs_main lock is needed only once the node information is retrieved with cs_vNodes.

  4. laanwj commented at 6:16 AM on June 6, 2014: member

    Holding only one at a time is great. But something is going wrong, somehow it's holding both cs_main and cs_vNodes at some point. This could be due to GetNodeStateStats aquiring the cs_main lock, as well.

    Also: in https://github.com/bitcoin/bitcoin/blob/master/src/qt/peertablemodel.cpp#L52 you should have the TRY_LOCK inside the braces instead of outside it if you want it to be released when execution flow leaves them.

  5. ashleyholman commented at 6:24 AM on June 6, 2014: contributor

    you should have the TRY_LOCK inside the braces instead of outside it if you want it to be released when execution flow leaves them

    Ahh, that would explain why it's holding both. I'll fix that. Should the fix go to the old pull request, or a new one?

  6. laanwj commented at 6:27 AM on June 6, 2014: member

    A new one; the old one has been merged, so cannot be changed anymore.

  7. ashleyholman commented at 6:29 AM on June 6, 2014: contributor

    How do I make with DEBUG_LOCKORDER?

  8. laanwj commented at 6:33 AM on June 6, 2014: member
    ./configure ... CPPFLAGS="-DDEBUG_LOCKORDER" 
    
  9. ashleyholman referenced this in commit 0b00dc2ec6 on Jun 6, 2014
  10. ashleyholman referenced this in commit b917555b04 on Jun 6, 2014
  11. laanwj referenced this in commit 345cb52e8b on Jun 6, 2014
  12. laanwj closed this on Jul 31, 2014

  13. MathyV referenced this in commit 716a3dd197 on Nov 3, 2014
  14. credits-currency referenced this in commit 85aeba5aad on Nov 18, 2015
  15. reddink referenced this in commit 3496b4c6a0 on Jun 9, 2016
  16. reddink referenced this in commit b6c6428851 on Jul 28, 2016
  17. reddink referenced this in commit 03c035ca45 on Aug 4, 2016
  18. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me