GitoxideLabs / gitoxide

An idiomatic, lean, fast & safe pure Rust implementation of Git
Apache License 2.0
8.91k stars 303 forks source link

Reenable CI fuzzing of pull requests #1596

Closed EliahKagan closed 3 weeks ago

EliahKagan commented 4 weeks ago

Per https://github.com/EliahKagan/gitoxide/pull/1#issuecomment-2351345353, it looks like I can't investigate this properly in a fork-internal PR. Ideally this will turn into a mergeable PR, but that is not the case yet, and it is not guaranteed.


The error is:

error[E0658]: `#[diagnostic]` attribute name space is experimental
   --> /rust/registry/src/index.crates.io-6f17d22bba15001f/serde-1.0.210/src/de/mod.rs:536:5
    |
536 |     diagnostic::on_unimplemented(
    |     ^^^^^^^^^^
    |
    = note: see issue #111996 <https://github.com/rust-lang/rust/issues/111996> for more information
    = help: add `#![feature(diagnostic_namespace)]` to the crate attributes to enable
    = note: this compiler was built on 2024-02-11; consider upgrading it if it is out of date

As noted in https://github.com/EliahKagan/gitoxide/pull/1#issuecomment-2308147716, this might be possible to fix by downgrading a dependency, though I would be reluctant to modify versions in Cargo.lock directly, which I expect could be undone automatically when changes are made to any Cargo.toml file anywhere in the workspace.

What I am not sure of is whether it should be done that way, or by using a newer toolchain by updating the Docker image. https://github.com/rust-lang/rust/issues/111996 is closed as completed. Does that mean using a newer rustc would avoid the problem?

EliahKagan commented 4 weeks ago

@Byron In https://github.com/EliahKagan/gitoxide/pull/1#issuecomment-2308147716 you had suggested that downgrading serde in Cargo.lock might help. This makes sense, since their versions were upgraded in #1536, where the breakage seems to have started. But does the build in the CI fuzzing job actually use locked dependencies? Is it intended to?

Byron commented 4 weeks ago

Thanks for looking into this! Admittedly I completely forget about it already and CI-Fuzzing would be lost in time.

@Byron In EliahKagan#1 (comment) you had suggested that downgrading serde in Cargo.lock might help. This makes sense, since their versions were upgraded in #1536, where the breakage seems to have started. But does the build in the CI fuzzing job actually use locked dependencies? Is it intended to?

It's true, I also have the impression it uses the the latest possible versions of dependencies, so Cargo.lock shouldn't matter for it.

So updating the image to use a more recent Rust version certainly would help. On top of that, I think the minimal rust-version supported by serde should also be adjusted to capture this dependency.

EliahKagan commented 3 weeks ago

So updating the image to use a more recent Rust version certainly would help.

I've opened https://github.com/google/oss-fuzz/pull/12512 for this.

I assume fuzzing is completely broken and not just when triggered by our CI, but I have only actually verified that it is broken on CI. I'm not sure how to check other runs, or even if I am able to do so, since I have no special access. (I have access to oss-fuzz reports for GitPython but not, as far as I know, for gitoxide.)

If that change is accepted and if it fixes the problem, this PR could then be merged to reenable CI fuzzing of pull requests, but if that is to be done, then the second commit here should either be dropped via force push, or reverted. This is because downgrading serde-related crates in Cargo.lock is ineffective at fixing fuzzing, and probably undesirable otherwise.

To aid with that, I've gone ahead and reverted that commit. But we can still force push back to the first commit, of course.

On top of that, I think the minimal rust-version supported by serde should also be adjusted to capture this dependency.

Based on https://github.com/serde-rs/serde/issues/2770, and specifically https://github.com/serde-rs/serde/issues/2770#issuecomment-2212162225, it looks like the issue is known and only occurs when using old nightly compilers, and that serde only attempts to support current nightly compilers. So based on that my guess is that there may not be anything to do in serde for this.

Eventually, I think the default version oss-fuzz uses of the nightly Rust compiler will be upgraded. See https://github.com/google/oss-fuzz/issues/12410. But we shouldn't have to wait for that to happen to fix this. As noted there and in https://github.com/google/oss-fuzz/pull/12512, the latest nightly is being used in a couple of projects to work around this (https://github.com/google/oss-fuzz/pull/12404, https://github.com/google/oss-fuzz/pull/12409).

Byron commented 3 weeks ago

Thanks a lot for the summary, I am looking forward to upstream merge so CI will be back here.

EliahKagan commented 3 weeks ago

This is working now, since https://github.com/google/oss-fuzz/pull/12512.


If this pull request is merged, then it might be a good idea, afterwards, to add the CIFuzz job as a required check for automatic merging. Considerations:

Breakages (if they do not reflect a possible bug due to changes a PR proposes) can reasonably be addressed by temporarily disabling CI fuzzing, as was done in #1536. (In unusual cases, they could possibly be addressed by manually merging pull requests for which fuzzing has failed but other checks have passed.)

This pull request does not attempt to introduce changes to cause fuzzing to be effectively required, because I don't know of a way to do that by editing workflows that is clearly better than configuring it manually.

1536, which (among other changes) removed the CIFuzz job that this PR restores, was merged on August 23, which was before #1551 was opened and merged on August 25. Reviewing #1551 therefore did not involve any considerations of whether fuzzing failures should block PRs. Because the CIFuzz job is in a different GitHub Actions workflow file from the jobs affected by #1551, a cross-workflow dependency would be needed to include it in a similar way. Since this is not necessarily clearer or more elegant than configuring it as required, I have not made that change here.