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

error: unsupported operation: can't call foreign function sigaltstack on OS linux #40

Open
yunji-yunji opened this issue Aug 9, 2023 · 1 comment

Comments

@yunji-yunji
Copy link

  • Command: FUZZCHECK_ARGS="my test" MIRIFLAGS=-Zmiri-disable-isolation cargo +miri2 miri run
  • Environment: Linux G22L059 5.19.0-50-generic #50-Ubuntu SMP PREEMPT_DYNAMIC Mon Jul 10 18:24:29 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

  1. Error 1: I got the following error when trying to execute the above command using my custom Rustc toolchain (named miri2)."
thread 'main' panicked at 'could not find all relevant LLVM coverage sections: CannotFindSection { section: CovMap }', /home/y23kim/rust/fuzzcheck-rs/fuzzcheck/src/code_coverage_sensor/mod.rs:55:57
  1. Error 2: When I modified this part(/home/y23kim/rust/fuzzcheck-rs/fuzzcheck/src/code_coverage_sensor/mod.rs:55:57) to return an empty CoverageSensor struct, above error was disappeared but another error occurred.
error: unsupported operation: can't call foreign function `sigaltstack` on OS `linux`
  --> /home/y23kim/rust/fuzzcheck-rs/fuzzcheck/src/signals_handler.rs:46:17
   |
46 |     let stack = libc::sigaltstack(&signal_stack, std::ptr::null_mut());
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't call foreign function `sigaltstack` on OS `linux`
   |
   = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support

Are these two errors caused by using my custom RustC and MIRI Toolchain? The second one seems like an obvious bug, but I'm unable to speculate on the cause of the first one.


I attached my main function for your information.

  1 #![allow(unused_attributes)]
  2 #![feature(no_coverage)]
  3 #![feature(impl_trait_in_assoc_type)]
  4 use std::fmt::Debug;
  5 use serde::{Deserialize, Serialize};
  6 use fuzzcheck::{DefaultMutator, Mutator};
  7 use fuzzcheck::mutators::tuples::TupleStructure;
  8 use fuzzcheck::mutators::testing_utilities::test_mutator;
  9 
 10 #[derive(Serialize, Deserialize)]
 11 #[derive(Clone, Debug, PartialEq, Eq, Hash, DefaultMutator)]
 12 struct SampleStruct2<T, U> {
 13     x: T,
 14     y: U,
 15     z: U,
 16 }
 17 
 18 
 19 fn fuzz_target(s: &SampleStruct2<u16, u16>) {
 20     if s.x > 3 {
 21         return;
 22     } else {
 23         let _tmp = s.x + s.y + s.z;
 24     }
 25 }
 26 
 27 
 28 fn main() {
 29 
 30     let m = SampleStruct2::<u8, u8>::default_mutator();
 31     test_mutator(m, 1000., 1000., false, true, 100, 100);
 32     let result = fuzzcheck::fuzz_test(fuzz_target)
 33         .default_mutator()
 34         .serde_serializer()
 35         .default_sensor_and_pool()
 36         .arguments_from_cargo_fuzzcheck()
 37         .stop_after_first_test_failure(true)
 38         .launch();
 39     println!("after result");
 40 }
@teymour-aldridge
Copy link
Collaborator

teymour-aldridge commented Oct 26, 2023

Hi, sorry for the delay.

Error 1 probably originates from not compiling your program with coverage counters enabled. You can either use cargo fuzzcheck or set the RUSTFLAGS=-C instrument-coverage environment variable to fix this.

I'm not really sure about Error 2, but my guess is that this may be a MIRI-specific issue (as the sigaltstack syscall may cause the interpreter some problems). Can you try running your program without using MIRI and see if the issue persists?

Even if MIRI doesn't work with Fuzzcheck, LLVM's santizers should work (other people have been able to use them without issue). Perhaps ASAN/MSAN might work for your use-case?

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