Skip to content
This repository was archived by the owner on Mar 22, 2024. It is now read-only.

Fix PR #15 : Fix style. Compute rss in mb. Add doc for new stats. - #23

Merged
jonathanmetzman merged 3 commits into
google:masterfrom
neuracr:rss_fix
Sep 5, 2019
Merged

jonathanmetzman merged 3 commits into
google:masterfrom
neuracr:rss_fix

Conversation

@neuracr

@neuracr neuracr commented Sep 4, 2019

Copy link
Copy Markdown
Contributor

Requested changes from #15.

  • Fix C style to comply with Google C++ style
  • Fix the computation of the rss value. Do the same as in libFuzzer
  • Add documentation for these 2 metrics
  • Fix the travis test to check for values in mb

Comment thread docs/status_screen.txt
@jonathanmetzman

jonathanmetzman commented Sep 4, 2019 •

Copy link
Copy Markdown
Contributor

Thanks!

I think the "non-hang" part of slowest_exec_ms isn't working 100% correctly. Try this:

// test.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

int main(int argc, char** argv) {

  char buf[8];

  if (read(0, buf, 8) < 3) {
    printf("Hum?\n");
    exit(1);
  }

  if (buf[0] == '0')
    printf("Looks like a zero to me!\n");
  else
    printf("A non-zero value? How quaint!\n");

  if (buf[2] == '1') {
    usleep(800000);
    printf("800000\n");
  }
  if (buf[2] == '2')
    abort();
  exit(0);
}
./afl-gcc test.c -o test && rm -rf /tmp/input && mkdir /tmp/input && echo "" > /tmp/input/1 && AFL_BENCH_UNTIL_CRASH=1 ./afl-fuzz -i  /tmp/i -o /tmp/hang -t100 ./test; cat /tmp/hang/fuzzer_stats

(may need to try a few times, but I pretty frequently get slowest_exec_ms: 801)

It seems to work until AFL exits (Ctrl-C also seems to break it).

Not sure if this is so important, I know AFL_BENCH_UNTIL_CRASH behaves weirdly and doesn't exit immediately anyway.

Comment thread afl-fuzz.c Outdated
else if (usage.ru_maxrss == 0) {
fprintf(f, "peak_rss_mb : not available while afl is running\n");
}
else{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add a space after else, and same comment as above (ie: } else {)

Comment thread afl-fuzz.c Outdated
WARNF("getrusage failed");
}
else if (usage.ru_maxrss == 0){
else if (usage.ru_maxrss == 0) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

let's also do } else if (usage.ru_maxrss == 0) { like the rest of the file, instead of putting else on newline.

@jonathanmetzman jonathanmetzman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@jonathanmetzman
jonathanmetzman merged commit c45fd01 into google:master Sep 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants