Sync w/Fedora 33 -- add missing patch:
gdb-rhbz1869484-deleted-working-directory
This commit is contained in:
parent
3ab415fc4a
commit
d7b61266b7
@ -412,3 +412,6 @@ Patch101: gdb-rhbz1844458-use-fputX_unfiltered.patch
|
||||
# (Aaron Merey, RH BZ 183877)
|
||||
Patch102: gdb-rhbz1838777-debuginfod.patch
|
||||
|
||||
# Backport patches fixing abort when working directory is deleted.
|
||||
Patch103: gdb-rhbz1869484-deleted-working-directory
|
||||
|
||||
|
@ -100,3 +100,4 @@
|
||||
%patch100 -p1
|
||||
%patch101 -p1
|
||||
%patch102 -p1
|
||||
%patch103 -p1
|
||||
|
@ -100,3 +100,4 @@ gdb-rhbz1822715-fix-python-deprecation.patch
|
||||
gdb-rhbz1829702-fix-python39.patch
|
||||
gdb-rhbz1844458-use-fputX_unfiltered.patch
|
||||
gdb-rhbz1838777-debuginfod.patch
|
||||
gdb-rhbz1869484-deleted-working-directory
|
||||
|
@ -1,15 +1,12 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Keith Seitz <keiths@redhat.com>
|
||||
Date: Mon, 8 Jun 2020 11:33:47 -0700
|
||||
From: Sergio Durigan Junior <sergiodj@redhat.com>
|
||||
Date: Wed, 19 Feb 2020 16:40:48 -0500
|
||||
Subject: gdb-rhbz1844458-use-fputX_unfiltered.patch
|
||||
|
||||
;; Fix fput?_unfiltered functions
|
||||
;; RH BZ 1844458 (Sergio Durigan Junior and Tom Tromey)
|
||||
|
||||
From 9effb44ccbf50c16da66aaab5fd535fe17e38e32 Mon Sep 17 00:00:00 2001
|
||||
From: Sergio Durigan Junior <sergiodj@redhat.com>
|
||||
Date: Wed, 19 Feb 2020 16:40:48 -0500
|
||||
Subject: [PATCH] Make '{putchar,fputc}_unfiltered' use 'fputs_unfiltered'
|
||||
Make '{putchar,fputc}_unfiltered' use 'fputs_unfiltered'
|
||||
|
||||
There is currently a regression when using
|
||||
'{putchar,fputc}_unfiltered' with 'puts_unfiltered' which was
|
||||
|
240
gdb-rhbz1869484-deleted-working-directory
Normal file
240
gdb-rhbz1869484-deleted-working-directory
Normal file
@ -0,0 +1,240 @@
|
||||
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||||
From: Kevin Buettner <kevinb@redhat.com>
|
||||
Date: Thu, 20 Aug 2020 20:52:12 -0700
|
||||
Subject: gdb-rhbz1869484-deleted-working-directory
|
||||
|
||||
;; Backport patches fixing abort when working directory is deleted.
|
||||
|
||||
Guard against 'current_directory == NULL' on gdb_abspath (PR gdb/23613)
|
||||
|
||||
Ref.: https://bugzilla.redhat.com/show_bug.cgi?id=1728147
|
||||
Ref.: https://sourceware.org/bugzilla/show_bug.cgi?id=23613
|
||||
|
||||
Hi,
|
||||
|
||||
This bug has been reported against Fedora GDB, but there's also an
|
||||
upstream bug. The problem reported is that GDB segfaults when the
|
||||
working directory is deleted. It's pretty use to reproduce it:
|
||||
|
||||
mkdir bla
|
||||
cd bla
|
||||
rmdir ../bla
|
||||
gdb echo
|
||||
|
||||
Debugging the problem is a bit tricky, because, since the current
|
||||
directory doesn't exist anymore, a corefile cannot be saved there.
|
||||
After a few attempts, I came up with the following:
|
||||
|
||||
gdb -ex 'shell mkdir bla' -ex 'cd bla' -ex 'shell rmdir ../bla' -ex 'r echo' ./gdb/gdb
|
||||
|
||||
This assumes that you're inside a build directory which contains
|
||||
./gdb/gdb, of course.
|
||||
|
||||
After investigating it, I found that the problem happens at
|
||||
gdb_abspath, where we're dereferencing 'current_directory' without
|
||||
checking if it's NULL:
|
||||
|
||||
...
|
||||
(concat (current_directory,
|
||||
IS_DIR_SEPARATOR (current_directory[strlen (current_directory) - 1])
|
||||
? "" : SLASH_STRING,
|
||||
...
|
||||
|
||||
So I fixed the problem with the patch below. The idea is that, if
|
||||
'current_directory' is NULL, then the final string returned should be
|
||||
just the "path".
|
||||
|
||||
After fixing the bug, I found a similar one reported against our
|
||||
bugzilla: PR gdb/23613. The problem is the same, but the reproducer
|
||||
is a bit different.
|
||||
|
||||
I really tried writing a testcase for this, but unfortunately it's
|
||||
apparently not possible to start GDB inside a non-existent directory
|
||||
with DejaGNU.
|
||||
|
||||
I regression tested this patch on the BuildBot, and no regressions
|
||||
were found.
|
||||
|
||||
gdb/ChangeLog:
|
||||
2019-12-14 Sergio Durigan Junior <sergiodj@redhat.com>
|
||||
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=1728147
|
||||
PR gdb/23613
|
||||
* bsd-kvm.c (bsd_kvm_target_open): Use 'gdb_abspath'.
|
||||
* corelow.c: Include 'gdbsupport/pathstuff.h'.
|
||||
(core_target_open): Use 'gdb_abspath'.
|
||||
* gdbsupport/pathstuff.c (gdb_abspath): Guard against
|
||||
'current_directory == NULL' case.
|
||||
* gdbsupport/pathstuff.h (gdb_abspath): Expand comment and
|
||||
explain what happens when 'current_directory' is NULL.
|
||||
* go32-nat.c (go32_nat_target::wait): Check if
|
||||
'current_directory' is NULL before call to 'chdir'.
|
||||
* source.c (add_path): Use 'gdb_abspath'.
|
||||
* top.c: Include 'gdbsupport/pathstuff.h'.
|
||||
(init_history): Use 'gdb_abspath'.
|
||||
(set_history_filename): Likewise.
|
||||
* tracefile-tfile.c: Include 'gdbsupport/pathstuff.h'.
|
||||
(tfile_target_open): Use 'gdb_abspath'.
|
||||
|
||||
Change-Id: Ibb0932fa25bc5c2d3ae4a7f64bd7f32885ca403b
|
||||
|
||||
diff --git a/gdb/bsd-kvm.c b/gdb/bsd-kvm.c
|
||||
--- a/gdb/bsd-kvm.c
|
||||
+++ b/gdb/bsd-kvm.c
|
||||
@@ -114,14 +114,13 @@ bsd_kvm_target_open (const char *arg, int from_tty)
|
||||
|
||||
if (arg)
|
||||
{
|
||||
- char *temp;
|
||||
-
|
||||
filename = tilde_expand (arg);
|
||||
if (filename[0] != '/')
|
||||
{
|
||||
- temp = concat (current_directory, "/", filename, (char *)NULL);
|
||||
+ gdb::unique_xmalloc_ptr<char> temp (gdb_abspath (filename));
|
||||
+
|
||||
xfree (filename);
|
||||
- filename = temp;
|
||||
+ filename = temp.release ();
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/gdb/corelow.c b/gdb/corelow.c
|
||||
--- a/gdb/corelow.c
|
||||
+++ b/gdb/corelow.c
|
||||
@@ -48,6 +48,7 @@
|
||||
#include "completer.h"
|
||||
#include "gdbsupport/filestuff.h"
|
||||
#include "build-id.h"
|
||||
+#include "gdbsupport/pathstuff.h"
|
||||
|
||||
#ifndef O_LARGEFILE
|
||||
#define O_LARGEFILE 0
|
||||
@@ -407,8 +408,7 @@ core_target_open (const char *arg, int from_tty)
|
||||
|
||||
gdb::unique_xmalloc_ptr<char> filename (tilde_expand (arg));
|
||||
if (!IS_ABSOLUTE_PATH (filename.get ()))
|
||||
- filename.reset (concat (current_directory, "/",
|
||||
- filename.get (), (char *) NULL));
|
||||
+ filename = gdb_abspath (filename.get ());
|
||||
|
||||
flags = O_BINARY | O_LARGEFILE;
|
||||
if (write_files)
|
||||
diff --git a/gdb/gdbsupport/pathstuff.c b/gdb/gdbsupport/pathstuff.c
|
||||
--- a/gdb/gdbsupport/pathstuff.c
|
||||
+++ b/gdb/gdbsupport/pathstuff.c
|
||||
@@ -134,7 +134,7 @@ gdb_abspath (const char *path)
|
||||
if (path[0] == '~')
|
||||
return gdb_tilde_expand_up (path);
|
||||
|
||||
- if (IS_ABSOLUTE_PATH (path))
|
||||
+ if (IS_ABSOLUTE_PATH (path) || current_directory == NULL)
|
||||
return make_unique_xstrdup (path);
|
||||
|
||||
/* Beware the // my son, the Emacs barfs, the botch that catch... */
|
||||
diff --git a/gdb/gdbsupport/pathstuff.h b/gdb/gdbsupport/pathstuff.h
|
||||
--- a/gdb/gdbsupport/pathstuff.h
|
||||
+++ b/gdb/gdbsupport/pathstuff.h
|
||||
@@ -44,7 +44,10 @@ extern gdb::unique_xmalloc_ptr<char>
|
||||
|
||||
Contrary to "gdb_realpath", this function uses CURRENT_DIRECTORY
|
||||
for the path expansion. This may lead to scenarios the current
|
||||
- working directory (CWD) is different than CURRENT_DIRECTORY. */
|
||||
+ working directory (CWD) is different than CURRENT_DIRECTORY.
|
||||
+
|
||||
+ If CURRENT_DIRECTORY is NULL, this function returns a copy of
|
||||
+ PATH. */
|
||||
|
||||
extern gdb::unique_xmalloc_ptr<char> gdb_abspath (const char *path);
|
||||
|
||||
diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c
|
||||
--- a/gdb/go32-nat.c
|
||||
+++ b/gdb/go32-nat.c
|
||||
@@ -507,7 +507,8 @@ go32_nat_target::wait (ptid_t ptid, struct target_waitstatus *status,
|
||||
}
|
||||
|
||||
getcwd (child_cwd, sizeof (child_cwd)); /* in case it has changed */
|
||||
- chdir (current_directory);
|
||||
+ if (current_directory != NULL)
|
||||
+ chdir (current_directory);
|
||||
|
||||
if (a_tss.tss_irqn == 0x21)
|
||||
{
|
||||
diff --git a/gdb/source.c b/gdb/source.c
|
||||
--- a/gdb/source.c
|
||||
+++ b/gdb/source.c
|
||||
@@ -542,8 +542,7 @@ add_path (const char *dirname, char **which_path, int parse_separators)
|
||||
new_name_holder.reset (concat (name, ".", (char *) NULL));
|
||||
#endif
|
||||
else if (!IS_ABSOLUTE_PATH (name) && name[0] != '$')
|
||||
- new_name_holder.reset (concat (current_directory, SLASH_STRING, name,
|
||||
- (char *) NULL));
|
||||
+ new_name_holder = gdb_abspath (name);
|
||||
else
|
||||
new_name_holder.reset (savestring (name, p - name));
|
||||
name = new_name_holder.get ();
|
||||
diff --git a/gdb/top.c b/gdb/top.c
|
||||
--- a/gdb/top.c
|
||||
+++ b/gdb/top.c
|
||||
@@ -54,6 +54,7 @@
|
||||
#include "gdb_select.h"
|
||||
#include "gdbsupport/scope-exit.h"
|
||||
#include "gdbarch.h"
|
||||
+#include "gdbsupport/pathstuff.h"
|
||||
|
||||
/* readline include files. */
|
||||
#include "readline/readline.h"
|
||||
@@ -2020,12 +2021,13 @@ init_history (void)
|
||||
that was read. */
|
||||
#ifdef __MSDOS__
|
||||
/* No leading dots in file names are allowed on MSDOS. */
|
||||
- history_filename = concat (current_directory, "/_gdb_history",
|
||||
- (char *)NULL);
|
||||
+ const char *fname = "_gdb_history";
|
||||
#else
|
||||
- history_filename = concat (current_directory, "/.gdb_history",
|
||||
- (char *)NULL);
|
||||
+ const char *fname = ".gdb_history";
|
||||
#endif
|
||||
+
|
||||
+ gdb::unique_xmalloc_ptr<char> temp (gdb_abspath (fname));
|
||||
+ history_filename = temp.release ();
|
||||
}
|
||||
read_history (history_filename);
|
||||
}
|
||||
@@ -2103,8 +2105,12 @@ set_history_filename (const char *args,
|
||||
directories the file written will be the same as the one
|
||||
that was read. */
|
||||
if (!IS_ABSOLUTE_PATH (history_filename))
|
||||
- history_filename = reconcat (history_filename, current_directory, "/",
|
||||
- history_filename, (char *) NULL);
|
||||
+ {
|
||||
+ gdb::unique_xmalloc_ptr<char> temp (gdb_abspath (history_filename));
|
||||
+
|
||||
+ xfree (history_filename);
|
||||
+ history_filename = temp.release ();
|
||||
+ }
|
||||
}
|
||||
|
||||
static void
|
||||
diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c
|
||||
--- a/gdb/tracefile-tfile.c
|
||||
+++ b/gdb/tracefile-tfile.c
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "xml-tdesc.h"
|
||||
#include "target-descriptions.h"
|
||||
#include "gdbsupport/buffer.h"
|
||||
+#include "gdbsupport/pathstuff.h"
|
||||
#include <algorithm>
|
||||
|
||||
#ifndef O_LARGEFILE
|
||||
@@ -470,8 +471,7 @@ tfile_target_open (const char *arg, int from_tty)
|
||||
|
||||
gdb::unique_xmalloc_ptr<char> filename (tilde_expand (arg));
|
||||
if (!IS_ABSOLUTE_PATH (filename.get ()))
|
||||
- filename.reset (concat (current_directory, "/", filename.get (),
|
||||
- (char *) NULL));
|
||||
+ filename = gdb_abspath (filename.get ());
|
||||
|
||||
flags = O_BINARY | O_LARGEFILE;
|
||||
flags |= O_RDONLY;
|
6
gdb.spec
6
gdb.spec
@ -37,7 +37,7 @@ Version: 9.2
|
||||
|
||||
# The release always contains a leading reserved number, start it at 1.
|
||||
# `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing.
|
||||
Release: 7%{?dist}
|
||||
Release: 8%{?dist}
|
||||
|
||||
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and LGPLv3+ and BSD and Public Domain and GFDL
|
||||
# Do not provide URL for snapshots as the file lasts there only for 2 days.
|
||||
@ -1189,6 +1189,10 @@ fi
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Mon Nov 2 2020 Kevin Buettner <kevinb@redhat.com> - 9.2-8
|
||||
- Backport patches fixing abort when working directory is deleted.
|
||||
(RHBZ 1869484, Sergio Durigan Junior)
|
||||
|
||||
* Mon Nov 2 2020 Keith Seitz <keiths@redhat.com> - 9.2-7
|
||||
- Fix missing debuginfo messages. (RH BZ 1887025)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user