-
Notifications
You must be signed in to change notification settings - Fork 275
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
Revert prev lint fix #1604
Revert prev lint fix #1604
Changes from 3 commits
5359885
94cc54c
e98c11a
f002ffb
2a5f3fa
53714cd
8ab0fb7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,10 +130,9 @@ def run_local_instance(startup_script: Optional[str] = None) -> bool: | |
"""Does the equivalent of "create_instance" for local experiments, runs | ||
|startup_script| in the background.""" | ||
command = ['/bin/bash', startup_script] | ||
with subprocess.Popen(command, | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.STDOUT): | ||
return new_process.ProcessResult(0, '', False) | ||
# pylint: disable=consider-using-with | ||
subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | ||
return new_process.ProcessResult(0, '', False).retcode == 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will always be true wont it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, maybe I can also fix it by adding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think the new code (after revert) will always be true. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The way it was before using a context manager (before a6a5a9a) was:
That indeed does not check anything about Popen. The important fix here though is to stop using the context manager. As per the documentation (https://docs.python.org/3/library/subprocess.html?highlight=popen#subprocess.Popen)
Using a context manager closes file descriptors and waits for the process to terminate, which is probably what is causing problems. This code probably needs to start the process, but not wait for its termination. My suggestion would be:
If we want to be extra careful, we should check that the subprocess is created successfully, but I think we will get an exception if that were not the case anyway. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, @aeflores! |
||
|
||
|
||
def create_instance_template(template_name, docker_image, env, project, zone): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,8 +91,8 @@ def run_neuzz(input_corpus, | |
'python2', './nn.py', '--output-folder', afl_output_dir, target_binary | ||
] | ||
print('[run_neuzz] Running command: ' + ' '.join(command)) | ||
with subprocess.Popen(command, stdout=output_stream, stderr=output_stream): | ||
pass | ||
# pylint: disable=consider-using-with | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this patch changes too much. I think with usage didn't make sense in the first location, but I don't see why you would change these other ones. I think it makes sense here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, I think I should have considered this case by case:
I am inclined to not use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you should get rid of it in gcloud.py. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see! |
||
subprocess.Popen(command, stdout=output_stream, stderr=output_stream) | ||
time.sleep(40) | ||
target_rel_path = os.path.relpath(target_binary, os.getcwd()) | ||
# Spinning up neuzz | ||
|
@@ -101,9 +101,11 @@ def run_neuzz(input_corpus, | |
target_rel_path, '@@' | ||
] | ||
print('[run_neuzz] Running command: ' + ' '.join(command)) | ||
with subprocess.Popen(command, stdout=output_stream, | ||
stderr=output_stream) as neuzz_proc: | ||
neuzz_proc.wait() | ||
# pylint: disable=consider-using-with | ||
neuzz_proc = subprocess.Popen(command, | ||
stdout=output_stream, | ||
stderr=output_stream) | ||
neuzz_proc.wait() | ||
|
||
|
||
def fuzz(input_corpus, output_corpus, target_binary): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this does anything to check if the command succeeded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It checks the return status of the command in the next line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like the same behaviour as before: https://github.com/google/fuzzbench/pull/1529/files#diff-f61c598f4891541e693644bbc9016e5841fcddc986ea967eb3e192586a8c57deL133
The previous return was a no-op that would've always returned True (side note: is this behaviour actually correct?)
@alan32liu would be good to make this more explicit in the PR description in the future to make it clearer to reviewers :)