From 03e15f123bf93fe378494fd64ed38ce609827b0b Mon Sep 17 00:00:00 2001 From: Karel Klic Date: Thu, 4 Feb 2010 14:30:14 +0100 Subject: Script which checkes duplicate ABRT hashes in Bugzilla --- src/Backtrace/abrt-bz-hashchecker | 54 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100755 src/Backtrace/abrt-bz-hashchecker (limited to 'src') diff --git a/src/Backtrace/abrt-bz-hashchecker b/src/Backtrace/abrt-bz-hashchecker new file mode 100755 index 0000000..fcd18c2 --- /dev/null +++ b/src/Backtrace/abrt-bz-hashchecker @@ -0,0 +1,54 @@ +#!/usr/bin/python +# -*- mode:python -*- +# Checks how many bugs in Bugzilla have the same hash. +# +# Please do not run this script unless it's neccessary to do so. +# It forces Bugzilla to send data related to thousands of bug reports. + +from bugzilla import RHBugzilla +from optparse import OptionParser +import sys +import os.path +import subprocess +import re + +parser = OptionParser(version="%prog 1.0") +parser.add_option("-u", "--user", dest="user", + help="Bugzilla user name (REQUIRED)", metavar="USERNAME") +parser.add_option("-p", "--password", dest="password", + help="Bugzilla password (REQUIRED)", metavar="PASSWORD") +parser.add_option("-b", "--bugzilla", dest="bugzilla", + help="Bugzilla URL (defaults to Red Hat Bugzilla)", metavar="URL") + +(options, args) = parser.parse_args() + +if not options.user or len(options.user) == 0: + parser.error("User name is required.\nTry {0} --help".format(sys.argv[0])) + +if not options.password or len(options.password) == 0: + parser.error("Password is required.\nTry {0} --help".format(sys.argv[0])) + +if not options.bugzilla or len(options.bugzilla) == 0: + options.bugzilla = "https://bugzilla.redhat.com/xmlrpc.cgi" + +bz = RHBugzilla() +bz.connect(options.bugzilla) +bz.login(options.user, options.password) + +buginfos = bz.query({'status_whiteboard_type':'allwordssubstr','status_whiteboard':'abrt_hash'}) + +print "{0} bugs found.".format(len(buginfos)) + +hashes = {} +for buginfo in buginfos: + hash = re.match("abrt_hash:([^ ]+)", buginfo.status_whiteboard).group(1) + if hash in hashes: + hashes[hash].append(buginfo.bug_id) + else: + hashes[hash] = [ buginfo.bug_id ] + print hash +bz.logout() + +for hash, ids in hashes.items(): + if len(ids) > 1: + print "Duplicates found: ", ids.join(", ") -- cgit From b0b94006fe549455cf6afeb69c7c800f616e326b Mon Sep 17 00:00:00 2001 From: Karel Klic Date: Thu, 4 Feb 2010 14:54:14 +0100 Subject: Print the number of duplicates found. --- src/Backtrace/abrt-bz-dupchecker | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/Backtrace/abrt-bz-dupchecker b/src/Backtrace/abrt-bz-dupchecker index 4484d39..df6dc8a 100755 --- a/src/Backtrace/abrt-bz-dupchecker +++ b/src/Backtrace/abrt-bz-dupchecker @@ -128,7 +128,11 @@ for key, value in database.items(): print "Total number of duplicate bugs detected: {0}".format(dupcount) print "------------------------------" +dupcount = 0 for key, value in database.items(): if len(value) > 1: + dupcount += len(value) - 1 print "Duplicates: {0}".format(value) print "Backtrace: {0}".format(key) + +print "{0} duplicates found." -- cgit From 16139497c7884fa3304ad66c35a0570d6a20db7a Mon Sep 17 00:00:00 2001 From: Karel Klic Date: Thu, 4 Feb 2010 14:54:50 +0100 Subject: Added some more noncrash frames. --- src/Backtrace/backtrace.c | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/Backtrace/backtrace.c b/src/Backtrace/backtrace.c index b65216b..9b697da 100644 --- a/src/Backtrace/backtrace.c +++ b/src/Backtrace/backtrace.c @@ -129,32 +129,37 @@ static bool frame_is_noncrash_frame(struct frame *frame) if (!frame->sourcefile) return false; + /* GDK */ + if (0 == strcmp(frame->function, "gdk_x_error") + && 0 == strcmp(frame->sourcefile, "gdkmain-x11.c")) + return true; + + /* X.org */ if (0 == strcmp(frame->function, "_XReply") && 0 == strcmp(frame->sourcefile, "xcb_io.c")) return true; - if (0 == strcmp(frame->function, "_XError") && 0 == strcmp(frame->sourcefile, "XlibInt.c")) return true; - - if (0 == strcmp(frame->function, "gdk_x_error") - && 0 == strcmp(frame->sourcefile, "gdkmain-x11.c")) + if (0 == strcmp(frame->function, "XSync") + && 0 == strcmp(frame->sourcefile, "Sync.c")) + return true; + if (0 == strcmp(frame->function, "process_responses") + && 0 == strcmp(frame->sourcefile, "xcb_io.c")) return true; + /* glib */ if (0 == strcmp(frame->function, "IA__g_log") && 0 == strcmp(frame->sourcefile, "gmessages.c")) return true; - if (0 == strcmp(frame->function, "IA__g_logv") && 0 == strcmp(frame->sourcefile, "gmessages.c")) return true; - - if (0 == strcmp(frame->function, "process_responses") - && 0 == strcmp(frame->sourcefile, "xcb_io.c")) + if (0 == strcmp(frame->function, "IA__g_assertion_message") + && 0 == strcmp(frame->sourcefile, "gtestutils.c")) return true; - - if (0 == strcmp(frame->function, "XSync") - && 0 == strcmp(frame->sourcefile, "Sync.c")) + if (0 == strcmp(frame->function, "IA__g_assertion_message_expr") + && 0 == strcmp(frame->sourcefile, "gtestutils.c")) return true; /* DBus */ @@ -165,6 +170,20 @@ static bool frame_is_noncrash_frame(struct frame *frame) && 0 == strcmp(frame->sourcefile, "dbus-gobject.c")) return true; + /* libstdc++ */ + if (0 == strcmp(frame->function, "__gnu_cxx::__verbose_terminate_handler") + && NULL != strstr(frame->sourcefile, "/vterminate.cc")) + return true; + if (0 == strcmp(frame->function, "__cxxabiv1::__terminate") + && NULL != strstr(frame->sourcefile, "/eh_terminate.cc")) + return true; + if (0 == strcmp(frame->function, "std::terminate") + && NULL != strstr(frame->sourcefile, "/eh_terminate.cc")) + return true; + if (0 == strcmp(frame->function, "__cxxabiv1::__cxa_throw") + && NULL != strstr(frame->sourcefile, "/eh_throw.cc")) + return true; + return false; } -- cgit From a4d4a5549684d4b454e4d1acdcaad89d230bb699 Mon Sep 17 00:00:00 2001 From: Karel Klic Date: Thu, 4 Feb 2010 16:07:11 +0100 Subject: Removed 4 shift/reduce conflicts --- src/Backtrace/parser.y | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Backtrace/parser.y b/src/Backtrace/parser.y index 1903282..c87bfa9 100644 --- a/src/Backtrace/parser.y +++ b/src/Backtrace/parser.y @@ -147,8 +147,8 @@ thread : keyword_thread wss digit_sequence wsa '(' keyword_thread wss digit_s } ; -frames : frame { $$ = $1; } - | frames wsa frame { $$ = frame_add_sibling($1, $3); } +frames : frame { $$ = $1; } + | frames frame { $$ = frame_add_sibling($1, $2); } ; frame : frame_head_1 wss variables %dprec 3 -- cgit From 2af5c6c7e6a1155b7d5096692c206b21b3bfd082 Mon Sep 17 00:00:00 2001 From: Karel Klic Date: Thu, 4 Feb 2010 16:08:07 +0100 Subject: Fix displaying dupcount. --- src/Backtrace/abrt-bz-dupchecker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Backtrace/abrt-bz-dupchecker b/src/Backtrace/abrt-bz-dupchecker index df6dc8a..0fd13f9 100755 --- a/src/Backtrace/abrt-bz-dupchecker +++ b/src/Backtrace/abrt-bz-dupchecker @@ -135,4 +135,4 @@ for key, value in database.items(): print "Duplicates: {0}".format(value) print "Backtrace: {0}".format(key) -print "{0} duplicates found." +print "{0} duplicates found.".format(dupcount) -- cgit From 170e252a1aa0bceca9e6f38593f083f55a4b6f3a Mon Sep 17 00:00:00 2001 From: Karel Klic Date: Thu, 4 Feb 2010 16:08:30 +0100 Subject: Skip broken hashes --- src/Backtrace/abrt-bz-hashchecker | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Backtrace/abrt-bz-hashchecker b/src/Backtrace/abrt-bz-hashchecker index fcd18c2..9c4a5ff 100755 --- a/src/Backtrace/abrt-bz-hashchecker +++ b/src/Backtrace/abrt-bz-hashchecker @@ -41,7 +41,12 @@ print "{0} bugs found.".format(len(buginfos)) hashes = {} for buginfo in buginfos: - hash = re.match("abrt_hash:([^ ]+)", buginfo.status_whiteboard).group(1) + match = re.search("abrt_hash:([^ ]+)", buginfo.status_whiteboard) + if not match: + continue + hash = match.group(1) + if not hash: + continue if hash in hashes: hashes[hash].append(buginfo.bug_id) else: -- cgit From 0308401fb1399186d22722364e262353dcd9d129 Mon Sep 17 00:00:00 2001 From: Karel Klic Date: Thu, 4 Feb 2010 16:31:50 +0100 Subject: Removed 5 shift/reduce conflicts --- src/Backtrace/parser.y | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Backtrace/parser.y b/src/Backtrace/parser.y index c87bfa9..42ac220 100644 --- a/src/Backtrace/parser.y +++ b/src/Backtrace/parser.y @@ -129,7 +129,7 @@ backtrace : /* empty */ %dprec 1 ; threads : thread - | threads wsa thread { $$ = thread_add_sibling($1, $3); } + | threads '\n' thread { $$ = thread_add_sibling($1, $3); } ; thread : keyword_thread wss digit_sequence wsa '(' keyword_thread wss digit_sequence wsa ')' ':' wsa frames -- cgit From ad55daf143dcf6f00f2c5000d0ab6c752e8ff323 Mon Sep 17 00:00:00 2001 From: Karel Klic Date: Thu, 4 Feb 2010 17:45:28 +0100 Subject: Component-wise duplicates --- src/Backtrace/abrt-bz-dupchecker | 46 +++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/Backtrace/abrt-bz-dupchecker b/src/Backtrace/abrt-bz-dupchecker index 0fd13f9..d7748c7 100755 --- a/src/Backtrace/abrt-bz-dupchecker +++ b/src/Backtrace/abrt-bz-dupchecker @@ -62,6 +62,8 @@ for buginfo in buginfos: print "Bug {0} has status {1}, skipping.".format(buginfo.bug_id, buginfo.bug_status) continue + bug = bz.getbug(buginfo.bug_id) + # Skip bugs with already downloaded backtraces. filename = "{0}.bt".format(buginfo.bug_id) if os.path.isfile(filename): @@ -69,7 +71,6 @@ for buginfo in buginfos: print "Skipping {0} (already exists).".format(filename) else: # Get backtrace from bug and store it as a file. - bug = bz.getbug(buginfo.bug_id) downloaded = False for attachment in bug.attachments: if attachment['filename'] == 'backtrace': @@ -95,7 +96,7 @@ for buginfo in buginfos: command.append("--remove-noncrash-frames") helper = subprocess.Popen(command, stdout=subprocess.PIPE) - out, err = helper.communicate() + backtrace, err = helper.communicate() helper.wait() if helper.returncode != 0: @@ -103,16 +104,21 @@ for buginfo in buginfos: continue # Empty backtrace is provided by Python apps. - if len(out) == 0: + if len(backtrace) == 0: continue - if out in database: - database[out].append(buginfo.bug_id) - if options.verbose: - print "Duplicate found: {0}".format(database[out]) - print "Backtrace: {0}".format(out) + bugitem = {'id':buginfo.bug_id, 'comments':len(bug.longdescs)} + if backtrace in database: + components = database[backtrace] + if buginfo.component in components: + components[buginfo.component].append(bugitem) + if options.verbose: + print "Duplicate found: {0}".format(database[out]['id']) + print "Backtrace: {0}".format(out) + else: + components[buginfo.component] = [ bugitem ] else: - database[out] = [ buginfo.bug_id ] + database[backtrace] = { buginfo.component: [ bugitem ] } bz.logout() @@ -121,18 +127,18 @@ print "========================================================================= # The number of duplicates. dupcount = 0 -for key, value in database.items(): - if len(value) > 1: - dupcount += len(value) - 1 +for backtrace, components in database.items(): + for component, bugitems in components.items(): + if len(bugitems) > 1: + dupcount += len(value) - 1 print "Total number of duplicate bugs detected: {0}".format(dupcount) print "------------------------------" -dupcount = 0 -for key, value in database.items(): - if len(value) > 1: - dupcount += len(value) - 1 - print "Duplicates: {0}".format(value) - print "Backtrace: {0}".format(key) - -print "{0} duplicates found.".format(dupcount) +# Print the duplicates +for backtrace, components in database.items(): + for component, bugitems in components.items(): + if len(bugitems) > 1: + print "Component: {0}".format(component) + print "Duplicates: {0}".format(map(lambda x: "{0} ({1})".format(x['id'],x['comments']), bugitems).join(", ")) + print "Backtrace: {0}".format(backtrace) -- cgit From baacc3cadfd08293e6f46bd84ab322d0cb67bf10 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 4 Feb 2010 19:22:38 +0100 Subject: abrtd: handle "perl -w /usr/bin/script" too Signed-off-by: Denys Vlasenko --- src/Daemon/MiddleWare.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Daemon/MiddleWare.cpp b/src/Daemon/MiddleWare.cpp index 2786938..c3f9061 100644 --- a/src/Daemon/MiddleWare.cpp +++ b/src/Daemon/MiddleWare.cpp @@ -566,13 +566,19 @@ void LoadOpenGPGPublicKey(const char* key) static char *get_argv1_if_full_path(const char* cmdline) { char *argv1 = (char*) strchr(cmdline, ' '); - if (argv1 != NULL) + while (argv1 != NULL) { /* we found space in cmdline, so it might contain * path to some script like: - * /usr/bin/python /usr/bin/system-control-network + * /usr/bin/python [-XXX] /usr/bin/system-control-network */ argv1++; + if (*argv1 == '-') + { + /* looks like -XXX in "perl -XXX /usr/bin/script.pl", skip */ + argv1 = strchr(argv1, ' '); + continue; + } /* if the string following the space doesn't start * with '/' it's probably not a full path to script * and we can't use it to determine the package name @@ -584,6 +590,7 @@ static char *get_argv1_if_full_path(const char* cmdline) int len = strchrnul(argv1, ' ') - argv1; /* cut the cmdline arguments */ argv1 = xstrndup(argv1, len); + break; } return argv1; } -- cgit