False positive collisions could occur because of GetBucketPosition #22554

issue janus opened this issue on July 26, 2021
  1. janus commented at 11:02 AM on July 26, 2021: none

    <!-- This issue tracker is only for technical issues related to Bitcoin Core. General bitcoin questions and/or support requests are best directed to the Bitcoin StackExchange at https://bitcoin.stackexchange.com. For reporting security issues, please read instructions at https://bitcoincore.org/en/contact/. If the node is "stuck" during sync or giving "block checksum mismatch" errors, please ensure your hardware is stable by running memtest and observe CPU temperature with a load-test tool such as linpack before creating an issue! -->

    <!-- Describe the issue -->

    In CAddrMan::Add_ method if pinfo->GetNewBucket(nKey, source, m_asmap) returns same value(within an instance), pinfo->GetBucketPosition(nKey, true, nUBucket) would also return same consecutive values. This could lead to collision when it is not real one.

    Expected behavior

    <!--- What behavior did you expect? -->

    Check should be made to confirm if pinfo is empty while checking fInsert.

    Actual behavior

    <!--- What was the actual behavior (provide screenshots if the issue is GUI-related)? -->

    Some addrman_new_collisions tests failed To reproduce

    <!--- How reliably can you reproduce the issue, what are the steps to do so? -->

    System information Ubuntu 20

    <!-- What version of Bitcoin Core are you using, where did you get it (website, self-compiled, etc)? -->

    Master

    <!-- What type of machine are you observing the error on (OS/CPU and disk type)? -->

    500GB, Linux

    <!-- GUI-related issue? What is your operating system and its version? If Linux, what is your desktop environment and graphical shell? -->

    <!-- Any extra information that might be useful in the debugging process. -->

    <!--- This is normally the contents of a `debug.log` or `config.log` file. Raw text or a link to a pastebin type site are preferred. -->

  2. janus added the label Bug on Jul 26, 2021
  3. maflcko commented at 12:05 PM on July 26, 2021: member

    Some addrman_new_collisions tests failed

    Do you have steps to reproduce?

  4. maflcko added the label P2P on Jul 26, 2021
  5. jnewbery commented at 12:37 PM on July 26, 2021: contributor

    If the same new bucket/position is selected, then we don't try to insert the entry again:

    https://github.com/bitcoin/bitcoin/blob/1488f55fa57a1400a57be837b574183f019c7855/src/addrman.cpp#L365-L367

    (if (vvNew[nUBucket][nUBucketPos] != nId) ensures that the entry isn't already in that position in the bucket)

  6. janus commented at 10:43 AM on July 28, 2021: none

    Some addrman_new_collisions tests failed

    Do you have steps to reproduce?

    I trying to see if I can achieve that. Which function is toString for uint256?

  7. willcl-ark commented at 11:31 AM on March 10, 2023: contributor

    @janus are you able to reproduce this with the current version of the software? If not perhaps this can be closed.

    Reading the codeblock as it stands today, it still appears that the entry will only be added if it does not already exist there:

    https://github.com/bitcoin/bitcoin/blob/f7bdcfc83f5753349018be3b5a663c8923d1a5eb/src/addrman.cpp#L605-L627

    Check should be made to confirm if pinfo is empty while checking fInsert.

    We will always have pinfo at the check, as it's either found and returned by Find(), or else is created with Create(), so I don't think I understand what this check would do.

    https://github.com/bitcoin/bitcoin/blob/f7bdcfc83f5753349018be3b5a663c8923d1a5eb/src/addrman.cpp#L563

    https://github.com/bitcoin/bitcoin/blob/f7bdcfc83f5753349018be3b5a663c8923d1a5eb/src/addrman.cpp#L600-L603

  8. maflcko commented at 11:35 AM on March 10, 2023: member

    Closing for now, but happy to reopen if there is more info provided.

  9. maflcko closed this on Mar 10, 2023

  10. bitcoin locked this on Mar 9, 2024

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-17 09:14 UTC

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