diff options
author | Jose Castillo <jose.mfcastillo@gmail.com> | 2019-09-06 12:13:27 +0200 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2019-10-03 14:55:41 +0100 |
commit | 3c0fe8b4e04f867fe8fa69c683fa208594042d63 (patch) | |
tree | 71e88b3bde23f41e07051721fba95384c177f1c3 | |
parent | c08657af4d13c4eb6630dabdcd332b31ccd09be8 (diff) | |
download | sos-3c0fe8b4e04f867fe8fa69c683fa208594042d63.tar.gz |
[sosreport] Fix unhandled Out of Memory exception
This patches attempts to address the Memory Error exception thrown
by sosreport when it attempts to compress the sosreport file.
An example of the backtrace thrown is the following:
Creating compressed archive...
[archive:TarFileArchive] An error occurred compressing the archive: [Errno 12] Cannot allocate memory
Traceback (most recent call last):
File "/usr/sbin/sosreport", line 25, in <module>
main(sys.argv[1:])
File "/usr/lib/python2.7/site-packages/sos/sosreport.py", line 1637, in main
sos.execute()
File "/usr/lib/python2.7/site-packages/sos/sosreport.py", line 1616, in execute
return self.final_work()
File "/usr/lib/python2.7/site-packages/sos/sosreport.py", line 1529, in final_work
checksum = self._create_checksum(archive, hash_name)
File "/usr/lib/python2.7/site-packages/sos/sosreport.py", line 1469, in _create_checksum
digest.update(archive_fp.read())
MemoryError
Closes: #1317
Resolves: #1777
Signed-off-by: Jose Castillo <jose.mfcastillo@gmail.com>
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r-- | sos/sosreport.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/sos/sosreport.py b/sos/sosreport.py index 11cae530..05d15929 100644 --- a/sos/sosreport.py +++ b/sos/sosreport.py @@ -1180,10 +1180,13 @@ class SoSReport(object): if not archive: return False - archive_fp = open(archive, 'rb') - digest = hashlib.new(hash_name) - digest.update(archive_fp.read()) - archive_fp.close() + try: + archive_fp = open(archive, 'rb') + digest = hashlib.new(hash_name) + digest.update(archive_fp.read()) + archive_fp.close() + except Exception: + self.handle_exception() return digest.hexdigest() def _write_checksum(self, archive, hash_name, checksum): |