Skip to content

Move timeout subtraction outside Engine.fuzz.#2108

Merged
oliverchang merged 9 commits intomasterfrom
engine-timeout
Nov 2, 2020
Merged

Move timeout subtraction outside Engine.fuzz.#2108
oliverchang merged 9 commits intomasterfrom
engine-timeout

Conversation

@oliverchang
Copy link
Collaborator

@oliverchang oliverchang commented Oct 22, 2020

Part of #2101

Currently it's not obvious at all to users of Engine.fuzz how long
fuzzing will go for when a max_time is passed.

Add Engine.fuzz_additional_processing_timeout so that the caller can
explicitly subtract the necessary processing time themselves if needed.

Remove engine_common.POSTPROCESSING_TIME. This was a holdout from the
launcher days. This is moved to the AFL launcher and can be removed
there as well once that's migrated to the Engine interface.

@google-cla google-cla bot added the cla: yes CLA signed. label Oct 22, 2020
@oliverchang
Copy link
Collaborator Author

/gcbrun

Currently it's not obvious at all to users of Engine.fuzz how long
fuzzing will go for when a max_time is passed.

Add Engine.fuzz_additional_processing_timeout so that the caller can
explicitly subtract the necessary processing time themselves if needed.

Remove engine_common.POSTPROCESSING_TIME. This was a holdout from the
launcher days. This is moved to the AFL launcher and can be removed
there as well once that's migrated to the Engine interface.
@oliverchang
Copy link
Collaborator Author

/gcbrun

@oliverchang
Copy link
Collaborator Author

/gcbrun

@oliverchang
Copy link
Collaborator Author

/gcbrun

@oliverchang
Copy link
Collaborator Author

/gcbrun

@oliverchang oliverchang changed the title WIP: Move timeout subtraction outside Engine.fuzz. Move timeout subtraction outside Engine.fuzz. Oct 28, 2020
Returns:
An int representing the number of seconds required.
"""
del options
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this needed for?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the new recommended approach to dealing with unused arguments:

https://google.github.io/styleguide/pyguide.html#214-decision

fuzz_test_timeout = environment.get_value('FUZZ_TEST_TIMEOUT')
additional_processing_time = engine_impl.fuzz_additional_processing_timeout(
options)
fuzz_test_timeout -= additional_processing_time
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we do -(-X), why not just return positive val from this function and add it here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a positive value. We negate it in the implementation of libFuzzer's fuzz_additional_processing_timeout because libfuzzer.get_fuzz_timeout() returned a negative value.

We can clean up libfuzzer.get_fuzz_timeout to return a positive value in the first place, but that needs to wait for further refactoring (including AFL->engien refactor) so that we can get rid of some env var overrides used for testing (e.g. HARD_TIMEOUT_OVERRIDE).

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok sounds good.

options = engine_impl.prepare(corpus_path, target_path, DATA_DIR)
options.arguments.append('-runs=10')
engine_impl.fuzz(target_path, options, TEMP_DIR, 10)
engine_impl.fuzz(target_path, options, TEMP_DIR, get_fuzz_timeout(5))
Copy link
Collaborator

Choose a reason for hiding this comment

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

This get_fuzz_timeout call is confusing, isnt it this signature ?
src/python/bot/fuzzers/libfuzzer.py:def get_fuzz_timeout(is_mutations_run, total_timeout=None):

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a different get_fuzz_timeout, local to this file:

@oliverchang oliverchang merged commit 2c9d296 into master Nov 2, 2020
@oliverchang oliverchang deleted the engine-timeout branch January 21, 2021 02:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes CLA signed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants