Missing cs_main lock in ProcessMessage() #5678

issue johannes87 opened this issue on January 19, 2015
  1. johannes87 commented at 2:23 PM on January 19, 2015: none

    ProcessMessage() in net.cpp calls "Misbehaving()", which requires the cs_main lock. However, the lock is not aquired in ProcessMessage.

  2. laanwj commented at 3:12 PM on January 19, 2015: member

    Good catch.

    The most straightforward solution would be for the function to do the locking itself, e.g. add a LOCK(cs_main) at the top of that function.

  3. laanwj added the label P2P on Jan 19, 2015
  4. johannes87 commented at 3:24 PM on January 19, 2015: none

    On a side note: wouldn't it be better, performance-wise, to use a separate lock for the mapNodeState data structure, instead of using the global cs_main lock?

  5. laanwj added the label Bug on Jan 19, 2015
  6. laanwj commented at 3:36 PM on January 19, 2015: member

    Yes, more granular locking would help performance. The cs_main lock is heavily contended. But be careful not to introduce deadlocks. Which is easier if the locks are properly encapsulated inside data structures, which is the direction things should be moving anyhow.

  7. johannes87 commented at 5:41 PM on January 22, 2015: none

    It looks like the lock in "ProcessBlockAvailability()" is missing, too?

  8. fanquake commented at 8:24 AM on October 10, 2016: member

    Closing as fixed in #7942

  9. fanquake closed this on Oct 10, 2016

  10. MarcoFalke locked this on Sep 8, 2021
Labels

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 21:15 UTC

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