ocurrent / bun

tired of typing afl-fuzz? try bun!
MIT License
50 stars 10 forks source link

0 available cores detected! #11

Open jmid opened 5 years ago

jmid commented 5 years ago

I'm Using opam with OCaml 4.07.1+afl on my MacBook Pro with macports. Crowbar (0.1) works. I can compile with ocamlbuild -package crowbar firsttry.native and run afl-fuzz manually:

$ afl-fuzz -i in -o out -- ./firsttry.native @@
afl-fuzz 2.52b by <lcamtuf@google.com>
[+] You have 4 CPU cores and 3 runnable tasks (utilization: 75%).
[+] Try parallel jobs - see /opt/local/share/doc/afl/parallel_fuzzing.txt.
...

I then got curious in giving bun a spin. I installed with opam install bun (installed bun.0.3.3). But when I run:

$ bun -i in -o out ./firsttry.native
07:34.46:Fuzzers launched: [].
$

and I get back the prompt (after the 5sec delay). Adding verbose flags helps a bit on the output:

$ bun -v -v -i in -o out ./firsttry.native
07:36.09:[EXEC:30310]['afl-gotcpu']
07:36.09:[EXEC:30311]['grep' 'more processes on ']
07:36.14:[INFO]0 available cores detected!
07:36.14:Fuzzers launched: [].
$

I can work around it by supplying -s though:

$ bun -v -v -s -i in -o out ./firsttry.native
07:37.45:[EXEC:30317]['afl-gotcpu']
07:37.45:[EXEC:30318]['grep' 'more processes on ']
07:37.50:[INFO]1 available cores detected!
07:37.50:[INFO]Executing /Users/jmid/.opam/4.07.1+afl/bin/afl-fuzz -m 200 -i in -o out -S 1 -- ./firsttry.native @@
07:37.50:[INFO]/Users/jmid/.opam/4.07.1+afl/bin/afl-fuzz launched: PID 30319
07:37.50:Fuzzer 1 (pid=30319) launched.
afl-fuzz 2.52b by <lcamtuf@google.com>
[+] Disabling the UI because AFL_NO_UI is set.
[+] You have 4 CPU cores and 2 runnable tasks (utilization: 50%).
[+] Try parallel jobs - see docs/parallel_fuzzing.txt.
...
icristescu commented 5 years ago

I also run into the same problem. dune runtest on macos, results in
15:39.20:[INFO]0 available cores detected!

I investigate it a bit, and this issue is because the command afl-getcpu has different outputs for macos and Linux:

in macos:

$ afl-gotcpu
afl-gotcpu 2.52b by <lcamtuf@google.com>
[*] Measuring gross preemption rate (this will take 5.00 sec)...

>>> PASS: You can probably run additional processes. <<<

in Linux:

$ afl-gotcpu
afl-gotcpu 2.49b by <lcamtuf@google.com>
[*] Measuring per-core preemption rate (this will take 1.00 sec)...
    Core #0: CAUTION (231%)

>>> CAUTION: You may still have 1 core available. <<<

You can also see this in the implementation of afl-gotcpu.

The problem is here:the number of cpu availables cannot be extracted from the output of the command.

The workaround is indeed to use the --single-core option but this defeats the purpose of bun.