Skip to content

Conversation

@theuni
Copy link
Member

@theuni theuni commented Jun 5, 2024

See comment here: #30161 (comment)

Our code failed these checks in three places, which have been fixed up here. Though these appear to have been harmless, adding the check avoids the copy in the self-assignment case so there should be no downside.

Additionally, minisketch failed the check as well. See bitcoin-core/minisketch#87
Edit: Done

After fixing up the violations, turn on the aggressive clang-tidy check.

Note for reviewers: git diff -w makes this trivial to review.

@DrahtBot
Copy link
Contributor

DrahtBot commented Jun 5, 2024

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK hebasto, TheCharlatan

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

No conflicts as of last run.

@hebasto
Copy link
Member

hebasto commented Jun 5, 2024

Concept ACK.

I've created a similar branch this morning following the discussion in #30161 :)

@theuni theuni force-pushed the clang-tidy-self-assign branch from 466e757 to 428932f Compare June 5, 2024 18:33
@DrahtBot
Copy link
Contributor

DrahtBot commented Jun 5, 2024

🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the
documentation.

Possibly this is due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.

Leave a comment here, if you need help tracking down a confusing failure.

Debug: https://github.com/bitcoin/bitcoin/runs/25855234654

@theuni
Copy link
Member Author

theuni commented Jun 5, 2024

@maflcko Hmm, how best to ignore the tidy false-positive in a leveldb header?

./leveldb/include/leveldb/status.h:106:24: error: operator=() does not handle self-assignment properly

It looks like we could add ExcludeHeaderFilterRegex to our tidy config, but that's not wired up until clang-tidy-19.

@maflcko
Copy link
Member

maflcko commented Jun 6, 2024

Could add a patch to the leveldb subtree?

@hebasto
Copy link
Member

hebasto commented Jun 6, 2024

Hmm, how best to ignore the tidy false-positive in a leveldb header?

FWIW, in the CMake staging branch, all subtrees are already excluded from being analyzed by clang-tidy.

@fanquake
Copy link
Member

fanquake commented Jun 6, 2024

FWIW, in the CMake staging branch, all subtrees are already excluded from being analyzed by clang-tidy.

Is that actually the behaviour we want for all subtrees? Sounds like it could just hide bugs, and no-one is running any checks in the upstream repos.

@theuni
Copy link
Member Author

theuni commented Jun 6, 2024

Hmm, how best to ignore the tidy false-positive in a leveldb header?

FWIW, in the CMake staging branch, all subtrees are already excluded from being analyzed by clang-tidy.

I believe (based on our .bear-tidy-config) that this is the case in current master as well. That's not the issue here, though.

What we're running into is a leveldb header that's included by dbwrapper.cpp, so excluding the leveldb build itself doesn't help.

theuni added a commit to theuni/bitcoin that referenced this pull request Jun 6, 2024
Belt-and suspenders after bitcoin#30234. Self-assignment should be safe _and_
discouraged.

We used to opt out of this warning because something deep in our
serialization/byteswapping code could self-assign, but that doesn't appear to
be the case anymore.
@hebasto hebasto mentioned this pull request Jun 6, 2024
@theuni
Copy link
Member Author

theuni commented Jun 7, 2024

Added a commit to work around in leveldb.

@fanquake Would you be ok with carrying this in our subtree? I'm not sure of a better solution.

fanquake added a commit that referenced this pull request Jun 10, 2024
15796d4 build: warn on self-assignment (Cory Fields)
53372f2 refactor: disable self-assign warning for tests (Cory Fields)

Pull request description:

  Belt-and suspenders after #30234. Self-assignment should be safe _and_ discouraged.

  We used to opt out of this warning because something deep in our serialization/byteswapping code could self-assign, but that doesn't appear to be the case anymore.

ACKs for top commit:
  maflcko:
    ACK 15796d4
  fanquake:
    ACK 15796d4 - not a huge fan of inline pragma usage, but this seems fine, given it's to work around an already-fixed compiler bug, and we'll only be carrying it for a shortish time in any case.

Tree-SHA512: 1f95f7c730b974ad1da55ebd381040bac312f2f380fff9d569ebab91d7c1963592a84d1613d81d96238c6f5a66aa40deebba68a76f6b24b02150d0a77c769654
@fanquake
Copy link
Member

@fanquake Would you be ok with carrying this in our subtree? I'm not sure of a better solution.

Yea I think that's fine.

fanquake added a commit that referenced this pull request Jun 13, 2024
…f97a96d9eb676c

cb59af3 Squashed 'src/minisketch/' changes from 3472e2f5ec..eb37a9b8e7 (fanquake)

Pull request description:

  Includes bitcoin-core/minisketch#87 which is used in #30234.
  Includes bitcoin-core/minisketch#88 which is used in #29876.

ACKs for top commit:
  sipa:
    utACK 89464ad
  theuni:
    utACK 89464ad

Tree-SHA512: 838a8c60856bfdf714da7d5d97e31d458290849ba5007d5c5bb7abb83d413ada6b4c16e45b0e060ff892b5785e6b664be9b6a666d04f0a414b0e359d64d3ad44
fanquake added a commit to bitcoin-core/leveldb-subtree that referenced this pull request Jun 13, 2024
7045a90 Ignore clang's self-assignment check (Cory Fields)

Pull request description:

  As-documented in the code, this is already safe so ignore the false-positive.

  Necessary to turn on the option in bitcoin/bitcoin#30234. Passes tests there.

ACKs for top commit:
  maflcko:
    ACK 7045a90

Tree-SHA512: 7afa7d4e170e84f022fde037f4de6e417ad08bbc0e3953f1f3ea88da41cda1cc913a70ce43d4f6973813e78b0a0a97238deb44f79b6089688094b1e27ed69e51
@theuni theuni force-pushed the clang-tidy-self-assign branch from 7b6dd5d to 2da83de Compare June 14, 2024 10:23
fanquake added a commit that referenced this pull request Jun 14, 2024
a37778d Squashed 'src/leveldb/' changes from e2f10b4e47..688561cba8 (fanquake)

Pull request description:

  Includes bitcoin-core/leveldb-subtree#41 which is used in #30234.

ACKs for top commit:
  theuni:
    utACK 95812d9

Tree-SHA512: 3d943695a3d33816cf5558b183f5629aa92a500a1544eecedf84952e93c8592a8cf0d554b88281fc0bad3c9e920ebcff1ed8edc12f8e73f36ed5335482beb829
theuni added 2 commits June 14, 2024 10:27
…idy check

Both of these cases appear to be harmless, but adding the tests allows us to
turn on the aggressive clang-tidy checks.
@theuni theuni force-pushed the clang-tidy-self-assign branch from 2da83de to 26a7f70 Compare June 14, 2024 10:27
Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 26a7f70, I have reviewed the code and it looks OK.

Copy link
Contributor

@sedited sedited left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 26a7f70

@fanquake fanquake merged commit 00feabf into bitcoin:master Jul 11, 2024
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Oct 30, 2024
a37778d Squashed 'src/leveldb/' changes from e2f10b4e47..688561cba8 (fanquake)

Pull request description:

  Includes bitcoin-core/leveldb-subtree#41 which is used in bitcoin#30234.

ACKs for top commit:
  theuni:
    utACK 95812d9

Tree-SHA512: 3d943695a3d33816cf5558b183f5629aa92a500a1544eecedf84952e93c8592a8cf0d554b88281fc0bad3c9e920ebcff1ed8edc12f8e73f36ed5335482beb829
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Feb 20, 2025
a37778d Squashed 'src/leveldb/' changes from e2f10b4e47..688561cba8 (fanquake)

Pull request description:

  Includes bitcoin-core/leveldb-subtree#41 which is used in bitcoin#30234.

ACKs for top commit:
  theuni:
    utACK 95812d9

Tree-SHA512: 3d943695a3d33816cf5558b183f5629aa92a500a1544eecedf84952e93c8592a8cf0d554b88281fc0bad3c9e920ebcff1ed8edc12f8e73f36ed5335482beb829
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request May 15, 2025
15796d4 build: warn on self-assignment (Cory Fields)
53372f2 refactor: disable self-assign warning for tests (Cory Fields)

Pull request description:

  Belt-and suspenders after bitcoin#30234. Self-assignment should be safe _and_ discouraged.

  We used to opt out of this warning because something deep in our serialization/byteswapping code could self-assign, but that doesn't appear to be the case anymore.

ACKs for top commit:
  maflcko:
    ACK 15796d4
  fanquake:
    ACK 15796d4 - not a huge fan of inline pragma usage, but this seems fine, given it's to work around an already-fixed compiler bug, and we'll only be carrying it for a shortish time in any case.

Tree-SHA512: 1f95f7c730b974ad1da55ebd381040bac312f2f380fff9d569ebab91d7c1963592a84d1613d81d96238c6f5a66aa40deebba68a76f6b24b02150d0a77c769654
@bitcoin bitcoin locked and limited conversation to collaborators Jul 11, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants