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

Add Windows/macOS/Linux and x86/arm64 fuzzing CI #255

Merged
merged 4 commits into from
Apr 19, 2019
Merged

Add Windows/macOS/Linux and x86/arm64 fuzzing CI #255

merged 4 commits into from
Apr 19, 2019

Conversation

avsm
Copy link
Member

@avsm avsm commented Apr 15, 2019

Azure Pipelines and cloud.drone.io

For the fuzz tests, this fixes #252, but how do we tell afl-fuzz how long to run for? (See .drone.yml, tweaks welcome to the command line). It's running atm on https://cloud.drone.io/mirage/ocaml-cstruct/6/1/2 which I hope is a public URL.

@avsm
Copy link
Member Author

avsm commented Apr 15, 2019

Windows is broken due to janestreet/jst-config#1 making cstruct-async uninstallable

@yomimono
Copy link
Contributor

how do we tell afl-fuzz how long to run for

I just used timeout for this, FWIW.

.drone.yml Outdated
- opam install -y .
- opam install -y crowbar fmt
- opam exec -- dune build fuzz/fuzz.exe
- mkdir out && mkdir in && echo bactrian > in/test
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're using bun you don't need to do this anymore - bun should take care of it for you.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i cant think of a pun involving bun but i pushed the change for fun and now i have to run

.drone.yml Outdated
- opam exec -- dune build fuzz/fuzz.exe
- mkdir out && mkdir in && echo bactrian > in/test
- opam pin add -y bun https://github.com/yomimono/ocaml-bun.git
- opam exec -- bun -i in -o out -- ./_build/default/fuzz/fuzz.exe
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's where I'd add a timeout invocation. It's done via dune runtest in this version, but https://github.com/yomimono/ocaml-test-stdlib/blob/primary/test/jbuild#L29 has the basic shape of how this was done in earlier bun invocations.

@talex5
Copy link
Contributor

talex5 commented Apr 17, 2019

It says:

# Run eval $(opam env) to update the current shell environment
+ dune build @fuzz
/usr/drone/bin/init: 50: /usr/drone/bin/init: dune: not found 

https://cloud.drone.io/mirage/ocaml-cstruct/13/1/2

@avsm
Copy link
Member Author

avsm commented Apr 17, 2019

Hm, this is now passing but the fuzzer appears to terminate too soon despite a 30 minute timeout. https://cloud.drone.io/mirage/ocaml-cstruct/17/1/2 -- any ideas whats up here?

@talex5
Copy link
Contributor

talex5 commented Apr 17, 2019

No idea. The summary is certainly disappointing:

Summary stats
=============

       Fuzzers alive : 48
      Total run time : 0 days, 0 hours
         Total execs : 0 million
    Cumulative speed : 0 execs/sec
       Pending paths : 48 faves, 48 total
  Pending per fuzzer : 1 faves, 1 total (on average)
       Crashes found : 0 locally unique

All fuzzers have terminated.

@yomimono
Copy link
Contributor

@kayceesrk reported a similar bug - ocurrent/bun#6 . I'm trying to figure out what process-handling mistake I'm making in bun that leads to this.

@avsm
Copy link
Member Author

avsm commented Apr 17, 2019

Hm, there have also been multiple spawn releases since you first wrote bun. Could be something in between like that...

@talex5
Copy link
Contributor

talex5 commented Apr 17, 2019

I'm not sure I understand how it's supposed to work. From a quick look, it seems that mon is a signal-handler that calls Unix.pause () to wait for the next signal, while the original program is also waiting on its own Unix.pause (). How does that work?

The main application finishes with:

    Printf.printf "Fuzzers launched.  Waiting %d seconds for the first status update...\n%!" delay;
    ignore @@ Unix.alarm delay;
    Ok (Unix.pause ())

Does that mean that if any signal handler ever returns then the program exits?

@yomimono
Copy link
Contributor

I'm not sure I understand how it's supposed to work.

To be honest I don't really remember what was going on here. I'm working on something else this afternoon but I'll try and figure out (1) the original intent (2) whether it ever worked outside of the testing scenario where it demonstrably worked for some test code.

@talex5
Copy link
Contributor

talex5 commented Apr 18, 2019

@yomimono : if you're busy with other things at the moment, I can take a look at the bun process logic.

This was slightly complex since it needs to avoid `system`
calls, so I modified the driver to never fail, but this requires
a small hack to maintain compat with OCaml 4.06

The gitattributes matter as otherwise line numbers change on
windows and the expect tests fail
@avsm
Copy link
Member Author

avsm commented Apr 19, 2019

And now it gets a lot of fuzzing done, hurrah! @yomimono @talex5

Fuzzers alive : 48
13296	Total run time : 1 days, 15 hours
13297	Total execs : 230 million
13298	Cumulative speed : 76960 execs/sec
13299	Pending paths : 0 faves, 1 total
13300	Pending per fuzzer : 0 faves, 0 total (on average)
13301	Crashes found : 0 locally unique
13302	
13303	

@avsm avsm merged commit e9eb240 into master Apr 19, 2019
@avsm avsm deleted the azure branch April 19, 2019 20:43
avsm added a commit to avsm/opam-repository that referenced this pull request Apr 19, 2019
…uct-sexp and cstruct-lwt (5.0.0)

CHANGES:

**Security**: This release tightens bounds checks to ensure
that data outside a given view (but still inside the underlying
buffer) cannot be accessed.

- `sub` does more checks (mirage/ocaml-cstruct#244 mirage/ocaml-cstruct#245 @hannesm @talex5 review by @dinosaure)
- `add_len` and `set_len` are now deprecated and will be removed
  in a future release. (mirage/ocaml-cstruct#251 @hannesm)
- do not add user-provided data for bounds checks
  (mirage/ocaml-cstruct#253 @hannesm, report and review by @talex5)
- improve CI to add fuzzing (mirage/ocaml-cstruct#255 mirage/ocaml-cstruct#252 @avsm @yomimono @talex5)

**Remove Unix dependency**: cstruct now uses the new `bigarray-compat`
library instead of Bigarray directly, to avoid a dependency on Unix
when using OCaml compilers less than 4.06.0.  This will break downstream
libraries that do not have a direct dependency on `Bigarray`.  Simply
fix it in your library by adding a `bigarray` dependency in your dune
file. (mirage/ocaml-cstruct#247 @TheLortex)

**Capability module**: To improve the safety of future code with stronger type
checking, this release introduces a new `Cstruct_cap` module which makes the
underlying Cstruct an abstract type instead of a record. In return for this
extra abstraction, the module can enforce read-only, write only, and read/write
buffers by tracking them as phantom type variables.  Although this library
shares an implementation internally with classic `Cstruct`, it is a significant
revision and so we will be gradually migrating to it.  Feedback on it is
welcome! (mirage/ocaml-cstruct#237 @dinosaure and many excited reviewers)

**Ppx compare functions**: A new `compare_X` function is generated for
`cenum` declarations. This respects custom ids supplied in the cenum
declaration and so is more robust than polymorphic compare (mirage/ocaml-cstruct#248 @emillon)

The CI has also been switched over to both Azure Pipelines and Drone in
addition to Travis, and as a result the tests all run on Windows, macOS,
various Linux distributions, on x86 and arm64 machines, and runs AFL
fuzz tests on the Drone cloud (mirage/ocaml-cstruct#255 @avsm).
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

Successfully merging this pull request may close these issues.

fuzz tests should be run from CI
3 participants