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 minifying an input #16

Closed
teymour-aldridge opened this issue Oct 23, 2021 · 7 comments
Closed

Error minifying an input #16

teymour-aldridge opened this issue Oct 23, 2021 · 7 comments

Comments

@teymour-aldridge
Copy link
Collaborator

I found a failing test case, however, trying to minify it fails:

error: linking with `cc` failed: exit status: 1
  = note: Undefined symbols for architecture x86_64:
            "___llvm_profile_runtime", referenced from:
                ___llvm_profile_runtime_user in fuzz_parser-10a0a12e83348750.fuzz_parser.6cb7562a-cgu.0.rcgu.o
               (maybe you meant: ___llvm_profile_runtime_user)
          ld: symbol(s) not found for architecture x86_64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

I'm on MacOS Catalina, x86_64.

@loiclec
Copy link
Owner

loiclec commented Oct 23, 2021

Usually this happens because some other target was compiled with -Zinstrument-coverage but fuzzcheck was not linked to that target (because it is not in its dependencies). But I suppose there could also be other reasons. Could you share the command you used to fuzz it, the command used to minify it, and maybe the structure of the crate? (e.g. is there a tests folder for integration tests? a binary target? where is the fuzz test located?)

@teymour-aldridge
Copy link
Collaborator Author

The crate is in https://github.com/bailion/compiler (to run the fuzzer I cd logic and then cargo +nightly fuzzcheck parse::fuzz::fuzz_parser fuzz --artifacts fuzz/artifacts) to minify I cd logic and then use cargo fuzzcheck "parse::fuzz::fuzz_parser" tmin --input-file fuzz/artifacts/fd859641f26cddae.json – unfortunately I don't have the failing test file to hand, because I fixed the bug).

@loiclec
Copy link
Owner

loiclec commented Oct 24, 2021

Thanks, I'll look into it :)

Note that if you don't use .stop_after_first_test_failure(true) and the panic is recoverable (i.e. it is not a segfault), then the artefacts will be stored at corpus/artifacts/ and be minified automatically. That's one way to get around this bug.

@loiclec
Copy link
Owner

loiclec commented Oct 24, 2021

I also took a very quick look at your grammar definition and, ouch, I need to make it much nicer define a concatenation of literals! I am thinking of using the regex-syntax crate and have a convenience method that maps a regex_syntax::Hir to a Grammar. Remind me to make that happen if it's not there next month :)

@teymour-aldridge
Copy link
Collaborator Author

I need to make it much nicer define a concatenation of literals

I was going to suggest that :)

@loiclec
Copy link
Owner

loiclec commented Oct 31, 2021

The regex thing is on GitHub now and will be part of the next release :)

As for this bug, I think it can be solved by adding --cargo-args="--lib" as argument to cargo fuzzcheck, but I'm not 100% sure.

Since this error is a bit confusing, I am thinking of adding a mandatory option that can be either:

  • --lib
  • --test <test target name>
  • --bin <binary name>

They would have the same meaning as when they are used on cargo test. The purpose is to make sure that only the right target (i.e. the one that contains the fuzz test and depends on fuzzcheck), is compiled.

@loiclec
Copy link
Owner

loiclec commented Nov 30, 2021

I forgot to give an update on this issue. But I think it is fixed now, as it is required to specify the target which contains the fuzz test through --lib (the default), --test, or --bin.

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