57 lines
1.9 KiB
Diff
57 lines
1.9 KiB
Diff
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
|
From: Tom de Vries <tdevries@suse.de>
|
|
Date: Fri, 7 Feb 2025 17:06:30 +0100
|
|
Subject: core-target-open-segfault.patch
|
|
|
|
;; Backport upstream commit 2fc56106422 which fixes a possible
|
|
;; segfault when opening a core file. This will drop out when we
|
|
;; rebase to 16.3 or 17.1
|
|
|
|
[gdb/corefiles] Fix segfault in core_target_open
|
|
|
|
On x86_64-freebsd, with test-case gdb.arch/i386-biarch-core.exp I run into a
|
|
segfault here in corelow.c:core_target_open:
|
|
...
|
|
{
|
|
gdb::unique_xmalloc_ptr<char> failing_command = make_unique_xstrdup
|
|
(bfd_core_file_failing_command (current_program_space->core_bfd ()));
|
|
if (failing_command != nullptr)
|
|
gdb_printf (_("Core was generated by `%s'.\n"),
|
|
failing_command.get ());
|
|
}
|
|
...
|
|
where bfd_core_file_failing_command returns nullptr, so the segfault happens
|
|
somewhere during "strdup (nullptr)".
|
|
|
|
There doesn't seem to be a need to make a copy of the string, so fix this by
|
|
dropping the make_unique_xstrdup.
|
|
|
|
Tested on x86_64-linux.
|
|
Tested the test-case on x86_64-freebsd.
|
|
|
|
Approved-By: Tom Tromey <tom@tromey.com>
|
|
|
|
PR corefiles/32634
|
|
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32634
|
|
|
|
(cherry picked from commit 9dd3d66b79a2907726f407039234ad8677e9df16)
|
|
|
|
diff --git a/gdb/corelow.c b/gdb/corelow.c
|
|
--- a/gdb/corelow.c
|
|
+++ b/gdb/corelow.c
|
|
@@ -1188,11 +1188,11 @@ core_target_open (const char *arg, int from_tty)
|
|
}
|
|
else
|
|
{
|
|
- gdb::unique_xmalloc_ptr<char> failing_command = make_unique_xstrdup
|
|
- (bfd_core_file_failing_command (current_program_space->core_bfd ()));
|
|
+ const char *failing_command
|
|
+ = bfd_core_file_failing_command (current_program_space->core_bfd ());
|
|
if (failing_command != nullptr)
|
|
gdb_printf (_("Core was generated by `%s'.\n"),
|
|
- failing_command.get ());
|
|
+ failing_command);
|
|
}
|
|
|
|
/* Clearing any previous state of convenience variables. */
|