Skip to content

fuzz: libFuzzer build failure "unexpected cfg condition value: max_level_*" #3424

@dergoegge

Description

@dergoegge

Building the fuzz harnesses for fuzzing with libFuzzer is broken when using a recent rust nightly.

$ rustc --version
rustc 1.85.0-nightly (7db7489f9 2024-11-25)
$ RUSTFLAGS="--cfg=secp256k1_fuzz --cfg=hashes_fuzz" cargo +nightly fuzz build --features "libfuzzer_fuzz" msg_ping_target
...
error: unexpected `cfg` condition value: `max_level_debug`
   --> /workdir/rust-lightning/lightning-rapid-gossip-sync/src/processing.rs:447:6
    |
447 | /                     log_given_level!(
448 | |                         self.logger,
449 | |                         level,
450 | |                         "Failed to apply channel update: {:?}",
451 | |                         err
452 | |                     );
    | |_____________________^
    |
    = note: expected values for `feature` are: `criterion`, `default`, and `std`
    = help: consider adding `max_level_debug` as a feature in `Cargo.toml`
    = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
    = note: this error originates in the macro `log_given_level` (in Nightly builds, run with -Z macro-backtrace for more info)
...
error: unexpected `cfg` condition value: `max_level_off`
   --> /workdir/rust-lightning/lightning-rapid-gossip-sync/src/processing.rs:466:3
    |
466 |         log_trace!(self.logger, "Done processing RGS data from {}", latest_seen_timestamp);
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: expected values for `feature` are: `criterion`, `default`, and `std`
    = help: consider adding `max_level_off` as a feature in `Cargo.toml`
    = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
    = note: this error originates in the macro `$crate::log_given_level` which comes from the expansion of the macro `log_trace` (in Nightly builds, run with -Z macro-backtrace for more info)
...

I'm able to work around this with the following patch:

diff --git a/lightning-rapid-gossip-sync/Cargo.toml b/lightning-rapid-gossip-sync/Cargo.toml
index 03efbde3..fb01aba8 100644
--- a/lightning-rapid-gossip-sync/Cargo.toml
+++ b/lightning-rapid-gossip-sync/Cargo.toml
@@ -12,6 +12,13 @@ Utility to process gossip routing data from Rapid Gossip Sync Server.
 [features]
 default = ["std"]
 std = ["bitcoin-io/std", "bitcoin_hashes/std"]
+max_level_off = []
+max_level_error = []
+max_level_warn = []
+max_level_info = []
+max_level_debug = []
+max_level_trace = []
+

 [dependencies]
 lightning = { version = "0.0.124", path = "../lightning", default-features = false }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions