Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

With miri errors are not highlighted #251

Closed
Ddystopia opened this issue Oct 27, 2024 · 10 comments
Closed

With miri errors are not highlighted #251

Ddystopia opened this issue Oct 27, 2024 · 10 comments

Comments

@Ddystopia
Copy link

Hello, which that conf added:

[jobs.miri]
command = ["cargo", "miri", "run", "--color", "always"]
need_stdout = true

bacon looks like this:

image

This is output if command is run directly:

image

@Canop
Copy link
Owner

Canop commented Nov 9, 2024

I don't reproduce this. What version of bacon are you using ? Can you provide a minimal project for reproduction ?

I mean: warnings and errors aren't recognized as such, because there's no miri analyzer yet, but there's color.

@Ddystopia
Copy link
Author

Ddystopia commented Nov 10, 2024

Steps to reproduce:

$ cargo new bacon_miri
    Creating binary (application) `bacon_miri` package
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
$ cd bacon_miri/
$ echo 'fn main() {
      unsafe {
          *(0xdeadbeef as *mut i32) = 42;
      }
  }
  ' > src/main.rs
$ echo '[jobs.miri]
  command = ["cargo", "miri", "run", "--color", "always"]
  need_stdout = true
  allow_warnings = true
  ' > bacon.toml
$ bacon --version
bacon 3.2.0

Terminal: alacritty

Note: those need_stdout = true and allow_warnings = true do not affect the situation

@Ddystopia
Copy link
Author

I cloned upstream (f552bc2), everything is the same:

image

@Canop
Copy link
Owner

Canop commented Nov 10, 2024

This is weird, it looks like miri doesn't always (but sometimes do) respect the --color parameter.

You can try cargo +nightly miri run --color always 2> out.txt then check with a cat out.txt

@Ddystopia
Copy link
Author

Yeah, it is exactly like that

�[1m�[32m    Finished�[0m �]8;;https://doc.rust-lang.org/cargo/reference/profiles.html#default-profiles�\`dev` profile [unoptimized + debuginfo]�]8;;�\ target(s) in 0.00s
�[1m�[32m     Running�[0m `/home/ddystopia/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo-miri runner target/miri/x86_64-unknown-linux-gnu/debug/bacon_miri`
warning: integer-to-pointer cast
 --> src/main.rs:3:10
  |
3 |         *(0xdeadbeef as *mut i32) = 42;
  |          ^^^^^^^^^^^^^^^^^^^^^^^^ integer-to-pointer cast
  |
  = help: this program is using integer-to-pointer casts or (equivalently) `ptr::with_exposed_provenance`, which means that Miri might miss pointer bugs in this program
  = help: see https://doc.rust-lang.org/nightly/std/ptr/fn.with_exposed_provenance.html for more details on that operation
  = help: to ensure that Miri does not miss bugs in your program, use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead
  = help: you can then set `MIRIFLAGS=-Zmiri-strict-provenance` to ensure you are not relying on `with_exposed_provenance` semantics
  = help: alternatively, `MIRIFLAGS=-Zmiri-permissive-provenance` disables this warning
  = note: BACKTRACE:
  = note: inside `main` at src/main.rs:3:10: 3:34

error: Undefined Behavior: memory access failed: expected a pointer to 4 bytes of memory, but got 0xdeadbeef[noalloc] which is a dangling pointer (it has no provenance)
 --> src/main.rs:3:9
  |
3 |         *(0xdeadbeef as *mut i32) = 42;
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got 0xdeadbeef[noalloc] which is a dangling pointer (it has no provenance)
  |
  = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
  = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
  = note: BACKTRACE:
  = note: inside `main` at src/main.rs:3:9: 3:39

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

error: aborting due to 1 previous error; 1 warning emitted

@Canop
Copy link
Owner

Canop commented Nov 10, 2024

rust-lang/miri#2284

@Ddystopia
Copy link
Author

Should this issue be closed?

@Canop
Copy link
Owner

Canop commented Nov 10, 2024

no

@Canop
Copy link
Owner

Canop commented Nov 10, 2024

I don't really see a way for bacon to restore the missing colors, but there could be a toggle (or a "miri" analyzer) a little more lenient in its parsing an recognizing errors and warnings without styling. This would allow bacon to recognize items, make the locations export work, etc.

@Canop
Copy link
Owner

Canop commented Nov 10, 2024

It's not really hard to detect, and it gives me this:
image

but without styling the tests for errors and warnings aren't really discriminant and there will be false positives :(

    } else if regex_is_match!("^error: ", content) && !regex_is_match!("^error: aborting due to", content) {
        LineType::Title(Kind::Error)
    } else if regex_is_match!("^warning: ", content) {
        LineType::Title(Kind::Warning)

@Canop Canop closed this as completed in 8da69a0 Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants