-
Notifications
You must be signed in to change notification settings - Fork 152
Fix binwalk (and entropy) file descriptor leak #749
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
base: master
Are you sure you want to change the base?
Changes from 2 commits
8d36b13
82a8e2f
d0fe8cf
287f73d
95e7f27
d7d996a
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -67,17 +67,18 @@ def __init__( | |||||
| resource_service: ResourceServiceInterface, | ||||||
| ): | ||||||
| super().__init__(resource_factory, data_service, resource_service) | ||||||
|
paulnoalhyt marked this conversation as resolved.
Outdated
|
||||||
| self.pool = ProcessPoolExecutor() | ||||||
|
|
||||||
| async def analyze(self, resource: Resource, config=None) -> BinwalkAttributes: | ||||||
| if not BINWALK_INSTALLED: | ||||||
| raise ComponentMissingDependencyError(self, BINWALK_TOOL) | ||||||
| pool = ProcessPoolExecutor() | ||||||
|
Member
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.
Suggested change
We only ever want this to spawn one direct child process, rather than a pool with one child for each CPU. Since we only ever want to run this one thing concurrently, does it still make sense to use a process pool and not a thread pool (not sure on the state of this stuff relative to the GIL these days)?
Contributor
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 seems like a usecase for the
Collaborator
Author
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. @whyitfor I think that having to start and stop a binwalk service wouldn't be very intuitive for users. We don't expect binwalk to keep running in the background when we're not using it. Also I don't think any other OFRAK analyzer is defined as an |
||||||
| async with resource.temp_to_disk() as temp_path: | ||||||
| # Should errors be handled the way they are in the `DataSummaryAnalyzer`? Likely to be | ||||||
| # overkill here. | ||||||
| offsets = await asyncio.get_running_loop().run_in_executor( | ||||||
| self.pool, _run_binwalk_on_file, temp_path | ||||||
| pool, _run_binwalk_on_file, temp_path | ||||||
| ) | ||||||
|
Comment on lines
69
to
71
Member
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. Should this also be wrapped in a |
||||||
| pool.shutdown(wait=True, cancel_futures=True) | ||||||
|
rbs-jacob marked this conversation as resolved.
Outdated
|
||||||
| return BinwalkAttributes(offsets) | ||||||
|
|
||||||
|
|
||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.