Backport several bugfix commits, inc. gdb bt generation fail

Generation of gdb backtraces in 2.10.10 is entirely broken. As
I was backporting that fix, I saw three other bug fix commits
that looked significant, so backported those too. One is needed
for the package to build at all (the g_type_class_add_private
replacement).
This commit is contained in:
Adam Williamson 2018-09-15 15:14:00 -07:00
parent d26d504519
commit bcfb1b554d
5 changed files with 297 additions and 1 deletions

View File

@ -0,0 +1,133 @@
From 94dc5d2783133cea27b1ae804d5b8a2da06808c5 Mon Sep 17 00:00:00 2001
From: Matej Habrnal <mhabrnal@redhat.com>
Date: Wed, 6 Jun 2018 14:04:09 +0200
Subject: [PATCH] ccpp: add %h and %e parameter into abrt-hook-ccpp
Without this commit core_pattern's parameter %h and %e was not
translated at all.
If there is a white space in executable filename, %e replaced only by
the first part of executable name (till the space). Hence we decided
to get executable name from /proc/PID/exe symlink exist.
Example:
If 'core_pattern = core.%h.%p.%t.%e' the result was
core.%h.26284.1469805542.sleep not
core.myshostmane.26284.1469805542.sleep with spaces
Related to #1587891
Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
---
src/hooks/abrt-hook-ccpp.c | 36 +++++++++++++++++++----------
src/hooks/abrt-install-ccpp-hook.in | 2 +-
2 files changed, 25 insertions(+), 13 deletions(-)
diff --git a/src/hooks/abrt-hook-ccpp.c b/src/hooks/abrt-hook-ccpp.c
index 1c4e45e5..40117fc8 100644
--- a/src/hooks/abrt-hook-ccpp.c
+++ b/src/hooks/abrt-hook-ccpp.c
@@ -65,13 +65,13 @@ static struct dump_dir *dd;
* %t - UNIX time of dump
* %P - global pid
* %I - crash thread tid
- * %e - executable filename (can contain white spaces)
+ * %h - hostname
+ * %e - executable filename (can contain white spaces, must be placed at the end)
* %% - output one "%"
*/
/* Hook must be installed with exactly the same sequence of %c specifiers.
- * Last one, %h, may be omitted (we can find it out).
*/
-static const char percent_specifiers[] = "%scpugtePi";
+static const char percent_specifiers[] = "%scpugtPIhe";
static char *core_basename = (char*) "core";
static DIR *open_cwd(pid_t pid)
@@ -146,7 +146,8 @@ static int setfscreatecon_raw(security_context_t context)
}
#endif
-static int open_user_core(uid_t uid, uid_t fsuid, gid_t fsgid, pid_t pid, char **percent_values)
+static int open_user_core(uid_t uid, uid_t fsuid, gid_t fsgid, pid_t pid,
+ char **percent_values, const char *executable_filename)
{
proc_cwd = open_cwd(pid);
if (proc_cwd == NULL)
@@ -196,7 +197,13 @@ static int open_user_core(uid_t uid, uid_t fsuid, gid_t fsgid, pid_t pid, char *
{
const char *val = "%";
if (specifier_num > 0) /* not %% */
+ {
val = percent_values[specifier_num - 1];
+ /* if %e (executable filename), use executable from
+ * /proc/PID/exe symlink if exists */
+ if (percent_specifiers[specifier_num] == 'e' && executable_filename)
+ val = executable_filename;
+ }
//log_warning("c:'%c'", c);
//log_warning("val:'%s'", val);
@@ -917,9 +924,9 @@ int main(int argc, char** argv)
if (argc < 8)
{
- /* percent specifier: %s %c %p %u %g %t %P %T */
- /* argv: [0] [1] [2] [3] [4] [5] [6] [7] [8] */
- error_msg_and_die("Usage: %s SIGNO CORE_SIZE_LIMIT PID UID GID TIME GLOBAL_PID GLOBAL_TID", argv[0]);
+ /* percent specifier: %s %c %p %u %g %t %P %I %h %e */
+ /* argv: [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] */
+ error_msg_and_die("Usage: %s SIGNO CORE_SIZE_LIMIT PID UID GID TIME GLOBAL_PID GLOBAL_TID HOSTNAME BINARY_NAME", argv[0]);
}
/* Not needed on 2.6.30.
@@ -1016,13 +1023,21 @@ int main(int argc, char** argv)
snprintf(path, sizeof(path), "%s/last-ccpp", g_settings_dump_location);
+ char *executable = get_executable_at(pid_proc_fd);
+ const char *last_slash = NULL;
+ if (executable)
+ {
+ last_slash = strrchr(executable, '/');
+ /* if the last_slash was found, skip it */
+ if (last_slash) ++last_slash;
+ }
+
/* Open a fd to compat coredump, if requested and is possible */
int user_core_fd = -1;
if (setting_MakeCompatCore && ulimit_c != 0)
/* note: checks "user_pwd == NULL" inside; updates core_basename */
- user_core_fd = open_user_core(uid, fsuid, fsgid, pid, &argv[1]);
+ user_core_fd = open_user_core(uid, fsuid, fsgid, pid, &argv[1], (const char *)last_slash);
- char *executable = get_executable_at(pid_proc_fd);
if (executable == NULL)
{
/* readlink on /proc/$PID/exe failed, don't create abrt dump dir */
@@ -1031,9 +1046,6 @@ int main(int argc, char** argv)
return create_user_core(user_core_fd, pid, ulimit_c);
}
- const char *last_slash = strrchr(executable, '/');
- /* if the last_slash was found, skip it */
- if (last_slash) ++last_slash;
/* ignoring crashes */
if (executable && is_path_ignored(setting_ignored_paths, executable))
diff --git a/src/hooks/abrt-install-ccpp-hook.in b/src/hooks/abrt-install-ccpp-hook.in
index 660c2091..f8c0c610 100755
--- a/src/hooks/abrt-install-ccpp-hook.in
+++ b/src/hooks/abrt-install-ccpp-hook.in
@@ -11,7 +11,7 @@ SAVED_PATTERN_DIR="@VAR_RUN@/abrt"
SAVED_PATTERN_FILE="@VAR_RUN@/abrt/saved_core_pattern"
HOOK_BIN="@libexecdir@/abrt-hook-ccpp"
# Must match percent_specifiers[] order in abrt-hook-ccpp.c:
-PATTERN="|$HOOK_BIN %s %c %p %u %g %t %P %I"
+PATTERN="|$HOOK_BIN %s %c %p %u %g %t %P %I %h %e"
# core_pipe_limit specifies how many dump_helpers can run at the same time
# 0 - means unlimited, but it's not guaranteed that /proc/<pid> of crashing
--
2.19.0

View File

@ -0,0 +1,62 @@
From af51c51636eb0ca318e62d4c712f2ba3e60ed9b0 Mon Sep 17 00:00:00 2001
From: Martin Kutlak <mkutlak@redhat.com>
Date: Tue, 28 Aug 2018 10:26:47 +0200
Subject: [PATCH] gui: Replace deprecated g_type_class_add_private
g_type_class_add_private will be deprecated in Glib 2.58 [1].
There is a G_DEFINE_TYPE_WITH_PRIVATE macro that can replace
the deprecated function and it is backwards compatible [2].
[1] blog.gtk.org/2018/07/11/news-from-glib-2-58
[2] bassi.io/articles/2013/06/21/the-king-is-dead
Signed-off-by: Martin Kutlak <mkutlak@redhat.com>
---
src/configuration-gui/abrt-config-widget.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/src/configuration-gui/abrt-config-widget.c b/src/configuration-gui/abrt-config-widget.c
index 62910db6..aa3b5c01 100644
--- a/src/configuration-gui/abrt-config-widget.c
+++ b/src/configuration-gui/abrt-config-widget.c
@@ -27,9 +27,6 @@
#include "libabrt.h"
#include <assert.h>
-#define ABRT_CONFIG_WIDGET_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE((o), TYPE_ABRT_CONFIG_WIDGET, AbrtConfigWidgetPrivate))
-
#define WID(s) GTK_WIDGET(gtk_builder_get_object(self->priv->builder, s))
#define UI_FILE_NAME "abrt-config-widget.glade"
@@ -107,7 +104,7 @@ struct AbrtConfigWidgetPrivate {
AbrtConfigWidgetOption options[_ABRT_OPT_END_];
};
-G_DEFINE_TYPE(AbrtConfigWidget, abrt_config_widget, GTK_TYPE_BOX)
+G_DEFINE_TYPE_WITH_PRIVATE(AbrtConfigWidget, abrt_config_widget, GTK_TYPE_BOX)
enum {
SN_CHANGED,
@@ -214,8 +211,6 @@ abrt_config_widget_class_init(AbrtConfigWidgetClass *klass)
object_class->finalize = abrt_config_widget_finalize;
- g_type_class_add_private(klass, sizeof(AbrtConfigWidgetPrivate));
-
s_signals[SN_CHANGED] = g_signal_new ("changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
@@ -413,7 +408,7 @@ abrt_config_widget_init(AbrtConfigWidget *self)
{
GError *error = NULL;
- self->priv = ABRT_CONFIG_WIDGET_GET_PRIVATE(self);
+ self->priv = abrt_config_widget_get_instance_private(self);
self->priv->builder = gtk_builder_new();
gtk_builder_set_translation_domain(self->priv->builder, GETTEXT_PACKAGE);
--
2.19.0

View File

@ -0,0 +1,42 @@
From 179843d3800f4dd66b143968792a81668a7b172a Mon Sep 17 00:00:00 2001
From: Jake Daryll Obina <jake.obina@gmail.com>
Date: Mon, 25 Jun 2018 11:52:11 +0800
Subject: [PATCH] harvest_vmcore: Fix missing argument error during
delete_and_close()
delete_and_close() requires a directory name argument and it is being called
without one. This argument is really not necessary though since the directory
name is already saved in the directory object (can be queried via the directory
object's name attribute), and it is the saved directory that is always deleted
regardless of the argument passed in.
Signed-off-by: Jake Daryll Obina <jake.obina@gmail.com>
---
src/hooks/abrt_harvest_vmcore.py.in | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/hooks/abrt_harvest_vmcore.py.in b/src/hooks/abrt_harvest_vmcore.py.in
index 7d4bba52..66c3ad37 100644
--- a/src/hooks/abrt_harvest_vmcore.py.in
+++ b/src/hooks/abrt_harvest_vmcore.py.in
@@ -128,13 +128,15 @@ def create_abrtd_info(dest, uuid):
return dd
-def delete_and_close(dd, dd_dirname):
+def delete_and_close(dd):
"""
Deletes the given dump directory and closes it.
dd - dump directory object
- dd_dirname - full path to dump directory
"""
+ # Save the directory name as the directory object could be destroyed during
+ # delete().
+ dd_dirname = dd.name
if not dd.delete() == 0:
sys.stderr.write("Unable to delete '%s'\n" % (dd_dirname))
return
--
2.19.0

View File

@ -0,0 +1,41 @@
From 057f8b0395a37765b856737cb25186c52b300389 Mon Sep 17 00:00:00 2001
From: Martin Kutlak <mkutlak@redhat.com>
Date: Tue, 24 Jul 2018 10:17:05 +0200
Subject: [PATCH] lib: Correct the syntax for gdb backtrace command
abrt-action-generate-backtrace generates backtraces with error message:
A syntax error in expression, near `full'.
According to the GDB documentation the correct syntax for backtrace
command is:
backtrace [n]
backtrace full [n]
- sourceware.org/gdb/onlinedocs/gdb/Backtrace.html
Signed-off-by: Martin Kutlak <mkutlak@redhat.com>
---
src/lib/hooklib.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/lib/hooklib.c b/src/lib/hooklib.c
index 135c7cde..b66fc119 100644
--- a/src/lib/hooklib.c
+++ b/src/lib/hooklib.c
@@ -353,11 +353,11 @@ char *get_backtrace(const char *dump_dir_name, unsigned timeout_sec, const char
/* Limit bt depth. With no limit, gdb sometimes OOMs the machine */
unsigned bt_depth = 1024;
const char *thread_apply_all = "thread apply all -ascending";
- const char *full = " full";
+ const char *full = "full ";
char *bt = NULL;
while (1)
{
- args[bt_cmd_index] = xasprintf("%s backtrace %u%s", thread_apply_all, bt_depth, full);
+ args[bt_cmd_index] = xasprintf("%s backtrace %s%u", thread_apply_all, full, bt_depth);
bt = exec_vp(args, /*redirect_stderr:*/ 1, timeout_sec, NULL);
free(args[bt_cmd_index]);
if ((bt && strnlen(bt, 256*1024) < 256*1024) || bt_depth <= 32)
--
2.19.0

View File

@ -61,10 +61,18 @@
Summary: Automatic bug detection and reporting tool
Name: abrt
Version: 2.10.10
Release: 4%{?dist}
Release: 5%{?dist}
License: GPLv2+
URL: https://abrt.readthedocs.org/
Source: https://github.com/abrt/%{name}/archive/%{version}/%{name}-%{version}.tar.gz
# Backported fix for https://bugzilla.redhat.com/show_bug.cgi?id=1629408
Patch0: 0001-lib-Correct-the-syntax-for-gdb-backtrace-command.patch
# Backport: fix use of deprecated function (breaks build, as -Werror is used)
Patch1: 0001-gui-Replace-deprecated-g_type_class_add_private.patch
# Backport: fix missing argument error in harvest_vmcore
Patch2: 0001-harvest_vmcore-Fix-missing-argument-error-during-del.patch
# Backport: ccpp: add %h and %e parameter into abrt-hook-ccpp
Patch3: 0001-ccpp-add-h-and-e-parameter-into-abrt-hook-ccpp.patch
BuildRequires: %{dbus_devel}
BuildRequires: gtk3-devel
BuildRequires: glib2-devel >= 2.43
@ -604,6 +612,10 @@ to the shell
%prep
%setup -q
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%build
autoconf
@ -1255,6 +1267,12 @@ killall abrt-dbus >/dev/null 2>&1 || :
%config(noreplace) %{_sysconfdir}/profile.d/abrt-console-notification.sh
%changelog
* Sat Sep 15 2018 Adam Williamson <awilliam@redhat.com> - 2.10.10-5
- Backport fix for RHBZ #1629408 (failed gdb backtrace generation)
- Backport fix for deprecated function use (broke build)
- Backport fix for argument error in harvest_vmcore
- Backport fix for missing parameter translations in abrt-hook-ccpp
* Thu Jul 12 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.10.10-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild