Skip to content

Conversation

@maflcko
Copy link
Member

@maflcko maflcko commented Aug 31, 2021

This makes memory bugs deterministic. -ftrivial-auto-var-init=pattern is incompatible with other memory sanitizers (like valgrind and msan), but that is irrelevant here, because the address sanitizer in this fuzz CI config is already incompatible with them.

-ftrivial-auto-var-init=pattern goes well with -fsanitize=bool and -fsanitize=enum, but those are already enabled via -fsanitize=undefined. See https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#available-checks

@fanquake fanquake added the Tests label Aug 31, 2021
@maflcko
Copy link
Member Author

maflcko commented Aug 31, 2021

See also google/oss-fuzz#5879

@fanquake
Copy link
Member

fanquake commented Aug 31, 2021

Concept ACK guessing this needs to use a newer Clang:
https://github.com/bitcoin/bitcoin/pull/22841/checks?check_run_id=3471928307

configure: error: unrecognized option: `-ftrivial-auto-var-init=pattern'

@maflcko
Copy link
Member Author

maflcko commented Aug 31, 2021

configure: error

Fixed

@fanquake
Copy link
Member

fanquake commented Sep 1, 2021

cc @guidovranken @agroce

@maflcko
Copy link
Member Author

maflcko commented Sep 1, 2021

This would catch the bug fixed in commit 3737126 . (Memory sanitizers also do that, but there shouldn't be any risk in making our asan config catch it as well.)

@jonatack
Copy link
Member

jonatack commented Sep 1, 2021

Interesting. I wrote a tiny section about the -ftrivial-auto-var-init=pattern option and listed some resources about default initialization (including a good list of pros/cons in #17627 (comment) by @practicalswift) a couple years ago in the notes of https://bitcoincore.reviews/17639 to try to understand some of its tradeoffs:

  • Pre-initialize variables with dummy values, e.g. compile with Clang -ftrivial-auto-var-init=pattern.
    • Testing sensitivity concerns, e.g. Suppress false positive warning about uninitialized entropy buffers #17627 (comment) by Gregory Maxwell.
    • If a flaw is introduced, it may be undetectable by valgrind.
    • Compilers can warn when they're certain a value will be
      undefined, and pre-emptive dummy initialization suppresses those warnings.
    • Valgrind has special macros that can be used to mark memory as undefined. It
      may be best if dummy initialization were to be always done via a macro that
      would allow disabling it for testing, or valgrind annotating it.

Concept ACK on running the option on its own in a CI task, for IIUC that would avoid the potential drawbacks.

@maflcko
Copy link
Member Author

maflcko commented Sep 1, 2021

I don't think those tradeoffs are relevant to the discussion here. valgrind (and other memory sanitizers) are already incompatible with asan, as mentioned in the OP.

@jonatack
Copy link
Member

jonatack commented Sep 1, 2021

I don't think those tradeoffs are relevant to the discussion here. valgrind (and other memory sanitizers) are already incompatible with asan, as mentioned in the OP.

I thought the information could be interesting for reviewers interested to learn more.

@maflcko
Copy link
Member Author

maflcko commented Sep 1, 2021

Ah yes, for general background information on the topic that serves as a good starting point.

@practicalswift
Copy link
Contributor

cr ACK fa0a5fa

@maflcko maflcko merged commit e567dd5 into bitcoin:master Sep 6, 2021
@maflcko maflcko deleted the 2109-ciFuzzPatt branch September 6, 2021 08:03
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Sep 7, 2021
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 6, 2022
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.

4 participants