← Back to team overview

apport-hackers team mailing list archive

[Merge] lp:~bdrung/apport/lp-1684535 into lp:apport

 

Benjamin Drung has proposed merging lp:~bdrung/apport/lp-1684535 into lp:apport.

Requested reviews:
  Apport upstream developers (apport-hackers)
Related bugs:
  Bug #1684535 in Apport: "Please support CoreDumpFile in crash file"
  https://bugs.launchpad.net/apport/+bug/1684535

For more details, see:
https://code.launchpad.net/~bdrung/apport/lp-1684535/+merge/389620

Support specifying a CoreDumpFile in the .crash file instead of requiring it to be included in the file.

Motivation: We transfer the core dump via network with lz4 compression. See Debian bug #857300 [1] for the collecting script.

[1] https://bugs.debian.org/857300
-- 
Your team Apport upstream developers is requested to review the proposed merge of lp:~bdrung/apport/lp-1684535 into lp:apport.
=== modified file 'apport/report.py'
--- apport/report.py	2020-06-09 21:41:57 +0000
+++ apport/report.py	2020-08-20 16:56:23 +0000
@@ -1623,6 +1623,14 @@
             else:
                 # value is a file path
                 core = self['CoreDump'][0]
+                if core.endswith(".lz4"):
+                    compressed_core = core
+                    (fd, core) = tempfile.mkstemp(prefix="apport_core_")
+                    atexit.register(os.unlink, core)
+                    subprocess.check_call(
+                        ["lz4", "--decompress", "--to-stdout", compressed_core], stdout=fd
+                    )
+                    os.close(fd)
 
             command += ['--ex', 'core-file ' + core]
 

=== modified file 'problem_report.py'
--- problem_report.py	2019-05-20 18:54:29 +0000
+++ problem_report.py	2020-08-20 16:56:23 +0000
@@ -204,6 +204,15 @@
         if key is not None:
             self.data[key] = self._try_unicode(value)
 
+        if "CoreDumpFile" in self.data:
+            coredumpfile = self.data.pop("CoreDumpFile")
+            if not coredumpfile.startswith("/"):
+                # Sanitize path (assumed it to be relative to the .crash file)
+                coredumpfile = os.path.join(
+                    os.path.dirname(os.path.abspath(file.name)), coredumpfile
+                )
+            self.data["CoreDump"] = (coredumpfile,)
+
         self.old_keys = set(self.data.keys())
 
     def extract_keys(self, file, bin_keys, dir):