[SATYR PATCH 1/2] unwind: Don't fail completely if fingerprinting fails

Martin Milata mmilata at redhat.com
Tue May 21 13:02:22 UTC 2013


The fingerprinting code is rather fragile and fingerprints are not
essential. If generating fingerprints fails, continue without them.

Partially fixes #81.

Signed-off-by: Martin Milata <mmilata at redhat.com>
---
 lib/abrt.c             | 13 +++++--------
 lib/core_fingerprint.c | 23 +++++++++++++++++++----
 2 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/lib/abrt.c b/lib/abrt.c
index 803455e..c331ece 100644
--- a/lib/abrt.c
+++ b/lib/abrt.c
@@ -73,11 +73,8 @@ sr_abrt_create_core_stacktrace(const char *directory,
     if (!core_stacktrace)
         return false;
 
-    bool success = sr_core_fingerprint_generate(core_stacktrace,
-                                                error_message);
-
-    if (!success)
-        return false;
+    sr_core_fingerprint_generate(core_stacktrace,
+                                 error_message);
 
     if (hash_fingerprints)
         sr_core_fingerprint_hash(core_stacktrace);
@@ -90,9 +87,9 @@ sr_abrt_create_core_stacktrace(const char *directory,
     strcat(json, "\n");
 
     char *core_backtrace_filename = sr_build_path(directory, "core_backtrace", NULL);
-    success = sr_string_to_file(core_backtrace_filename,
-                                json,
-                                error_message);
+    bool success = sr_string_to_file(core_backtrace_filename,
+                                    json,
+                                    error_message);
 
     free(core_backtrace_filename);
     free(json);
diff --git a/lib/core_fingerprint.c b/lib/core_fingerprint.c
index d153f8b..461c953 100644
--- a/lib/core_fingerprint.c
+++ b/lib/core_fingerprint.c
@@ -31,6 +31,7 @@
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <search.h>
 
 static void
 fingerprint_add_bool(struct sr_strbuf *buffer,
@@ -363,23 +364,35 @@ fp_calltree_leaves(struct sr_strbuf *fingerprint,
     return true;
 }
 
+static void
+do_nothing(void *something)
+{
+}
+
 bool
 sr_core_fingerprint_generate(struct sr_core_stacktrace *stacktrace,
                              char **error_message)
 {
+    /* binary tree that works as a set of already processed binaries */
+    void *processed_files = NULL;
+    bool result = false;
+
     struct sr_core_thread *thread = stacktrace->threads;
     while (thread)
     {
         struct sr_core_frame *frame = thread->frames;
         while (frame)
         {
-            if (!frame->fingerprint && frame->file_name)
+            if (frame->file_name &&
+                !tfind(frame->file_name, &processed_files, (comparison_fn_t)strcmp))
             {
                 bool success = sr_core_fingerprint_generate_for_binary(
                     thread, frame->file_name, error_message);
 
-                if (!success)
-                    return false;
+                result |= success;
+
+                /* add file_name to the set of already processed files */
+                tsearch(frame->file_name, &processed_files, (comparison_fn_t)strcmp);
             }
 
             frame = frame->next;
@@ -388,7 +401,9 @@ sr_core_fingerprint_generate(struct sr_core_stacktrace *stacktrace,
         thread = thread->next;
     }
 
-    return true;
+    tdestroy(processed_files, do_nothing);
+
+    return result;
 }
 
 static bool
-- 
1.7.11.7



More information about the Crash-catcher mailing list