Skip to content

Conversation

maflcko
Copy link
Member

@maflcko maflcko commented Jul 11, 2023

The FUZZ_TARGET macros have many issues:

  • The developer will have to pick the right macro to pass the wanted option.
  • Adding a new option requires doubling the number of existing macros in the worst case.

Fix all issues by using only a single macro.

This refactor does not change behavior.

@DrahtBot
Copy link
Contributor

DrahtBot commented Jul 11, 2023

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

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK dergoegge
Concept ACK sipa

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #27888 (Fuzz: a more efficient descriptor parsing target by darosior)
  • #27552 (Add support for "partial" fuzzers that indicate usefulness by sipa)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@sipa
Copy link
Member

sipa commented Jul 11, 2023

Concept ACK

Copy link
Member

@dergoegge dergoegge left a comment

Choose a reason for hiding this comment

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

Concept ACK

Adding a new option requires doubling the number of existing macros in the worst case.

I've run into this before and it is indeed pretty annoying.

@maflcko
Copy link
Member Author

maflcko commented Jul 11, 2023

Thanks for the comments. Fixed everything.

@maflcko maflcko force-pushed the 2307-fuzz-macro- branch 2 times, most recently from fa35b0c to fa6fa1f Compare July 11, 2023 15:23
Copy link
Member

@dergoegge dergoegge left a comment

Choose a reason for hiding this comment

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

Code review ACK fa6fa1f

@maflcko maflcko force-pushed the 2307-fuzz-macro- branch 2 times, most recently from fa64a9f to fa34d1f Compare July 13, 2023 18:05
MarcoFalke added 2 commits July 13, 2023 20:37
* This allows to reduce the number of total macros.
* Also, adding a new option no longer requires doubling the number of
  macros in the worst case.
-BEGIN VERIFY SCRIPT-

  ren() { sed --regexp-extended -i "s|$1|$2|g" $(git grep -l --extended-regexp "$1"); }

  # Replace FUZZ_TARGET_INIT
  ren 'FUZZ_TARGET_INIT\((.+), (.+)\)' 'FUZZ_TARGET(\1, .init = \2)'

  # Delete unused FUZZ_TARGET_INIT
  sed -i -e '37,39d' src/test/fuzz/fuzz.h

-END VERIFY SCRIPT-
{
const auto it_ins = FuzzTargets().try_emplace(name, std::move(target), std::move(init), hidden);
const auto it_ins{FuzzTargets().try_emplace(name, FuzzTarget /* temporary can be dropped in C++20 */ {std::move(target), std::move(opts)})};
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
const auto it_ins{FuzzTargets().try_emplace(name, FuzzTarget /* temporary can be dropped in C++20 */ {std::move(target), std::move(opts)})};
const auto it_ins{FuzzTargets().try_emplace(name, std::move(target), std::move(opts))};

Haven't tracked down which C++20 LWG paper this was. Let me know if someone finds something.

Copy link
Member

@dergoegge dergoegge left a comment

Choose a reason for hiding this comment

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

ACK fa6dfaa

@fanquake fanquake merged commit bf03fed into bitcoin:master Jul 17, 2023
@maflcko maflcko deleted the 2307-fuzz-macro- branch July 17, 2023 12:48
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jul 17, 2023
fa6dfaa scripted-diff: Use new FUZZ_TARGET macro everywhere (MarcoFalke)
fa36ad8 fuzz: Accept options in FUZZ_TARGET macro (MarcoFalke)

Pull request description:

  The `FUZZ_TARGET` macros have many issues:
  * The developer will have to pick the right macro to pass the wanted option.
  * Adding a new option requires doubling the number of existing macros in the worst case.

  Fix all issues by using only a single macro.

  This refactor does not change behavior.

ACKs for top commit:
  dergoegge:
    ACK fa6dfaa

Tree-SHA512: 49a34553867a1734ce89e616b2d7c29b784a67cd8990db6573f0c7b18957636ef0c81d3d0d444a04c12cdc98bc4c4aa7a2ec94e6232dc363620a746e28416444
@sipa sipa mentioned this pull request Jul 17, 2023
@bitcoin bitcoin locked and limited conversation to collaborators Jul 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants