|
|
0a406a |
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
|
|
0a406a |
From: Kevin Buettner <kevinb@redhat.com>
|
|
|
0a406a |
Date: Wed, 17 Feb 2021 17:58:54 -0700
|
|
|
0a406a |
Subject: gdb-rhbz1912985-libstdc++-assert.patch
|
|
|
0a406a |
|
|
|
0a406a |
;; Backport fix for libstdc++ assert when performing tab completion
|
|
|
0a406a |
;; (RH BZ 1912985).
|
|
|
0a406a |
|
|
|
0a406a |
Fix completion related libstdc++ assert when using -D_GLIBCXX_DEBUG
|
|
|
0a406a |
|
|
|
0a406a |
This commit fixes a libstdc++ assertion failure encountered when
|
|
|
0a406a |
running gdb.base/completion.exp. In order to see this problem,
|
|
|
0a406a |
GDB must be built with the follow CFLAGS and CXXFLAGS as part
|
|
|
0a406a |
of the configure line:
|
|
|
0a406a |
|
|
|
0a406a |
CFLAGS='-D_GLIBCXX_DEBUG' CXXFLAGS='-D_GLIBCXX_DEBUG'
|
|
|
0a406a |
|
|
|
0a406a |
(Also, this problem was encountered using Fedora rawhide. It might
|
|
|
0a406a |
not be reproducible in Fedora versions prior to Fedora 34.)
|
|
|
0a406a |
|
|
|
0a406a |
Using the gdb.base/completion.exp test program, the problem can be
|
|
|
0a406a |
observed as follows:
|
|
|
0a406a |
|
|
|
0a406a |
[kev@rawhide-1 gdb]$ ./gdb -q testsuite/outputs/gdb.base/completion/completion
|
|
|
0a406a |
Reading symbols from testsuite/outputs/gdb.base/completion/completion...
|
|
|
0a406a |
(gdb) start
|
|
|
0a406a |
Temporary breakpoint 1 at 0x401179: file ../../worktree-master/gdb/testsuite/gdb.base/break.c, line 43.
|
|
|
0a406a |
Starting program: testsuite/outputs/gdb.base/completion/completion
|
|
|
0a406a |
|
|
|
0a406a |
Temporary breakpoint 1, main (argc=1, argv=0x7fffffffd718, envp=0x7fffffffd728) at ../../worktree-master/gdb/testsuite/gdb.base/break.c:43
|
|
|
0a406a |
43 if (argc == 12345) { /* an unlikely value < 2^16, in case uninited */ /* set breakpoint 6 here */
|
|
|
0a406a |
(gdb) p <TAB>/usr/include/c++/11/string_view:211: constexpr const value_type& std::basic_string_view<_CharT, _Traits>::operator[](std::basic_string_view<_CharT, _Traits>::size_type) const [with _CharT = char; _Traits = std::char_traits<char>; std::basic_string_view<_CharT, _Traits>::const_reference = const char&; std::basic_string_view<_CharT, _Traits>::size_type = long unsigned int]: Assertion '__pos < this->_M_len' failed.
|
|
|
0a406a |
Aborted (core dumped)
|
|
|
0a406a |
|
|
|
0a406a |
(Note that I added "<TAB>" to make it clear where the tab key was
|
|
|
0a406a |
pressed.)
|
|
|
0a406a |
|
|
|
0a406a |
gdb/ChangeLog:
|
|
|
0a406a |
|
|
|
0a406a |
* ada-lang.c (ada_fold_name): Check for non-empty string prior
|
|
|
0a406a |
to accessing it.
|
|
|
0a406a |
(ada_lookup_name_info): Likewise.
|
|
|
0a406a |
|
|
|
0a406a |
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
|
|
|
0a406a |
--- a/gdb/ada-lang.c
|
|
|
0a406a |
+++ b/gdb/ada-lang.c
|
|
|
0a406a |
@@ -997,7 +997,7 @@ ada_fold_name (gdb::string_view name)
|
|
|
0a406a |
int len = name.size ();
|
|
|
0a406a |
GROW_VECT (fold_buffer, fold_buffer_size, len + 1);
|
|
|
0a406a |
|
|
|
0a406a |
- if (name[0] == '\'')
|
|
|
0a406a |
+ if (!name.empty () && name[0] == '\'')
|
|
|
0a406a |
{
|
|
|
0a406a |
strncpy (fold_buffer, name.data () + 1, len - 2);
|
|
|
0a406a |
fold_buffer[len - 2] = '\000';
|
|
|
0a406a |
@@ -13597,7 +13597,7 @@ ada_lookup_name_info::ada_lookup_name_info (const lookup_name_info &lookup_name)
|
|
|
0a406a |
{
|
|
|
0a406a |
gdb::string_view user_name = lookup_name.name ();
|
|
|
0a406a |
|
|
|
0a406a |
- if (user_name[0] == '<')
|
|
|
0a406a |
+ if (!user_name.empty () && user_name[0] == '<')
|
|
|
0a406a |
{
|
|
|
0a406a |
if (user_name.back () == '>')
|
|
|
0a406a |
m_encoded_name
|