Clippy: 'rustc' stack overflow, but I can't find more information

Heya, I have a cargo clippy .. command which returns:

thread 'rustc' has overflowed its stack
fatal runtime error: stack overflow
child failed with signal `6`
error: could not compile `peace_cmd_rt` (lib)

However, cargo +stable clippy .. works.

So the questions:

  1. If this were to be opened as an issue on github, should I open an issue in the rust-lang/rust repo, or the rust-lang/clippy repo?

  2. I couldn't produce an MCVE; but if anyone wants to try and troubleshoot it:

    1. I tried gdbing the rust command that came out of cargo clippy -vv .., but it segfaults so I (think I) can't get a back trace

    2. I'm using rustc 1.74.0-nightly (203c57dbe 2023-09-17)

    3. Repo cloning commands (azriel91/peace):

      git clone git@github.com:azriel91/peace.git
      cd peace
      git switch feature/141/cancel-safety
      
    4. The commit that introduced this behaviour is likely a55d4584 (2 commits back, or 3, if you count the first one); it shows up on the latest commit as well as I was trying to fix it.

    5. clippy command I'm running (I'm on nightly by default, and add +stable for stable):

      # rustc 1.74.0-nightly (203c57dbe 2023-09-17)
      cargo clippy \
        --workspace \
        --features "cli error_reporting output_progress" \
        --fix \
        --exclude peace_rt_model_web \
        -- -D warnings
      
    6. I tried RUST_MIN_STACK=20000000 cargo clippy .. but the outcome was the same.

    7. You can add cargo clippy --vv .. to get the failing command, then <vars> gdb --args <the_command> to try play with gdb.

      This is where I stopped, as I hit a segfault and I haven't used gdb for ages.

    8. I suspect the overflow may be to do with: crate/cmd_rt/src/cmd_execution.rs:136, i.e.

      • the async fn cmd_outcome_task (crazy signature, sorry), in combination with
      • CmdBlockRtBox, which is a type alias for Pin<Box<dyn CmdBlockRt<..>>
      • many trait bounds

Any help would be much appreciated, but I know the project is non-trivial.

Thank you :bowing_man:

2 Likes

There's probably infinite recursion, so the stack will always overflow no matter how large you make it.

Running in gdb is the way to go. It should stop on overflow, and then use bt to show the backtrace.

You can also try lldb -- rustc <args>, then run and bt.

FYI no errors on the same nightly version based on the latest commit 1f3561dfd413919912 of your repo.

There was! I've opened rust-clippy#11533

ah, the error is in the feature/141/cancel-safety branch (but thank you for trying),

Also turns out latest rust nightly changed how it runs clippy:

  • nightly from maybe 1 week ago runs .../clippy-driver ... directly
  • latest nightly (2023-09-17) runs .../cargo .../rustc and connects to a separate process via socket

The command from the previous nightly works under gdb, and the current nightly doesn't (it fails to connect to socket), so I was lucky I had the clippy-driver command saved.