aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorKevin Buettner <kevinb@redhat.com>2021-02-12 17:53:51 -0700
committerKevin Buettner <kevinb@redhat.com>2021-02-17 17:26:55 -0700
commit6a780b6766378e3dc9610cba7e12d7eaba196f52 (patch)
treeee995877d93c61636ae2a918c2446ef538edd7f9 /gdb
parentafadac6170d88662156e540fdeb79a323261984c (diff)
downloadgdb-6a780b6766378e3dc9610cba7e12d7eaba196f52.zip
gdb-6a780b6766378e3dc9610cba7e12d7eaba196f52.tar.gz
gdb-6a780b6766378e3dc9610cba7e12d7eaba196f52.tar.bz2
Fix completion related libstdc++ assert when using -D_GLIBCXX_DEBUG
This commit fixes a libstdc++ assertion failure encountered when running gdb.base/completion.exp. In order to see this problem, GDB must be built with the follow CFLAGS and CXXFLAGS as part of the configure line: CFLAGS='-D_GLIBCXX_DEBUG' CXXFLAGS='-D_GLIBCXX_DEBUG' (Also, this problem was encountered using Fedora rawhide. It might not be reproducible in Fedora versions prior to Fedora 34.) Using the gdb.base/completion.exp test program, the problem can be observed as follows: [kev@rawhide-1 gdb]$ ./gdb -q testsuite/outputs/gdb.base/completion/completion Reading symbols from testsuite/outputs/gdb.base/completion/completion... (gdb) start Temporary breakpoint 1 at 0x401179: file ../../worktree-master/gdb/testsuite/gdb.base/break.c, line 43. Starting program: testsuite/outputs/gdb.base/completion/completion Temporary breakpoint 1, main (argc=1, argv=0x7fffffffd718, envp=0x7fffffffd728) at ../../worktree-master/gdb/testsuite/gdb.base/break.c:43 43 if (argc == 12345) { /* an unlikely value < 2^16, in case uninited */ /* set breakpoint 6 here */ (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. Aborted (core dumped) (Note that I added "<TAB>" to make it clear where the tab key was pressed.) gdb/ChangeLog: * ada-lang.c (ada_fold_name): Check for non-empty string prior to accessing it. (ada_lookup_name_info): Likewise.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/ada-lang.c4
2 files changed, 8 insertions, 2 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 204bb40..030eb9f 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2021-02-17 Kevin Buettner <kevinb@redhat.com>
+
+ * ada-lang.c (ada_fold_name): Check for non-empty string prior
+ to accessing it.
+ (ada_lookup_name_info): Likewise.
+
2021-02-13 Mike Frysinger <vapier@gentoo.org>
* aclocal.m4: Regenerate.
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 416a45b..419347f 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -980,7 +980,7 @@ ada_fold_name (gdb::string_view name)
int len = name.size ();
GROW_VECT (fold_buffer, fold_buffer_size, len + 1);
- if (name[0] == '\'')
+ if (!name.empty () && name[0] == '\'')
{
strncpy (fold_buffer, name.data () + 1, len - 2);
fold_buffer[len - 2] = '\000';
@@ -13650,7 +13650,7 @@ ada_lookup_name_info::ada_lookup_name_info (const lookup_name_info &lookup_name)
{
gdb::string_view user_name = lookup_name.name ();
- if (user_name[0] == '<')
+ if (!user_name.empty () && user_name[0] == '<')
{
if (user_name.back () == '>')
m_encoded_name