On Fri, Jul 29, 2016 at 10:01:12PM +0200, Kurt Roeckx wrote:
>
> Just running afl-showmap twice on the same input generates the
> same output. I've actually tried this before mailing.
>
> I guess I need to make something that reads that file 1 time and
> something that reads that file 2 times.
So I made something that did what is inside the __AFL_LOOP() 1 or
2 times depending on an argument to the program, so that afl still
uses the same numbers.
I've started by profiling that program. I expected one of the
RUN_ONCEs to cause this. They should be used for all the
initialization of global variables, and are clearly a point where
comming a second time you'll take the different branch. In the "ct"
program there only seems to be one of them: do_ex_data_init
So I made sure that that is called before the __AFL_LOOP(). This
changed the stability from 71.49% to 71.10%, and I really can't
explain why it makes it worse.
So I used gcc's -finstrument-functions to trace all the calls.
Before my change it clearly shows that do_ex_data_init() is called
during the first time the function is executed, but not anymore
during the second time. With calling do_ex_data_init() early
it shows them the 2 calls are now calling the same functions.
So gcc's -finstrument-functions shows that at least all the same
functions are called in the same order now, but that of course
doesn't mean anything about the same branches being taken.
I'm not sure how to convince gcov how to start collecting data
from a certain point, so that I can see either the first or
the second call.
Using afl-showmap calling the function 1 or 2 times originally had
2 different branches, after the early do_ex_data_init() call it
only shows 1. But the counters seems to react strangly. I expect
that all branches should be taken twice as often, except a few
expection that should be the same. But that's clearly not the case,
there are way more the same amount than I expect (49), there are
also that are less often which makes no sense at all, some
that are only 1 more which also makes little sense. And I guess
looking at those numbers in the showmap file, I can understand
that it's saying it's not stable.
I'm clearly not any closer to understanding why I'm getting that
and external tools currently don't seem to be providing much
inside at the moment.
Does someone have any ideas?
Kurt