Go to file
Simon Marchi 02646f1960 gdbsupport: fix path_join crash with -std=c++17 and -D_GLIBCXX_DEBUG
When building GDB with -std=c++17 and -D_GLIBCXX_DEBUG=1, I get:

  $ ./gdb -nx --data-directory=data-directory -q -ex "maint selftest path_join"
  /usr/include/c++/11.2.0/string_view:233: 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.

The problem is that we're passing an empty string_view to
IS_ABSOLUTE_PATH.  IS_ABSOLUTE_PATH accesses [0] on that string_view,
which is out-of-bounds.

The reason this is not seen with -std less than c++17 is that our local
copy of string_view (used with C++ < 17) does not have the assert in
operator[], as that wouldn't work in a constexpr method:

  5890af36e5/gdbsupport/gdb_string_view.h (L180)

IS_ABSOLUTE_PATH is normally used with null-terminated string.  It's
fine to pass an empty null-terminated string to IS_ABSOLUTE_PATH,
because index 0 in such a string is valid.  But not with an empty
string_view.

Fix that by avoiding the "call" to IS_ABSOLUTE_PATH if the string_view
is empty.

Change-Id: Idf4df961b63f513b3389235e93814c02b89ea32e
2022-05-19 08:04:13 -04:00
bfd COFF: use hash for string table also when copying / stripping 2022-05-19 12:45:55 +02:00
binutils COFF/PE: don't leave zero timestamp after objcopy / strip 2022-05-19 12:44:32 +02:00
config
contrib
cpu opcodes cgen: remove use of PTR 2022-05-11 09:49:20 +09:30
elfcpp
etc
gas Arm64: force emission of ILP32-dependent relocs 2022-05-19 12:46:21 +02:00
gdb Use aarch64_features to describe register features in target descriptions. 2022-05-18 13:32:04 -07:00
gdbserver Use aarch64_features to describe register features in target descriptions. 2022-05-18 13:32:04 -07:00
gdbsupport gdbsupport: fix path_join crash with -std=c++17 and -D_GLIBCXX_DEBUG 2022-05-19 08:04:13 -04:00
gnulib gnulib: update to bd11400942d6 2022-05-02 10:54:19 -04:00
gold Fix compile time warning building gold with Clang-14. 2022-05-18 16:29:57 +01:00
gprof gprof: remove use of PTR 2022-05-10 11:21:37 +09:30
gprofng gprofng: include percentages in default metrics list 2022-05-09 22:42:09 -07:00
include AArch64: Enable FP16 by default for Armv9-A. 2022-05-18 10:37:10 +01:00
intl
ld Fix an illegal memory access when creating DLLs. 2022-05-12 12:55:20 +01:00
libbacktrace
libctf libctf: impose an ordering on conflicting types 2022-04-28 11:47:12 +01:00
libdecnumber
libiberty Import libiberty from gcc 2022-05-13 16:43:15 +09:30
opcodes x86: shrink op_riprel 2022-05-18 14:39:58 +02:00
readline gdb/readline: fix extra 'quit' message problem 2022-05-07 10:49:27 +01:00
sim sim: remove use of PTR 2022-05-13 14:32:54 +09:30
texinfo
zlib
.cvsignore
.editorconfig
.gitattributes
.gitignore
ar-lib
ChangeLog
compile
config-ml.in
config.guess
config.rpath
config.sub
configure
configure.ac
COPYING
COPYING3
COPYING3.LIB
COPYING.LIB
COPYING.LIBGLOSS
COPYING.NEWLIB
depcomp
djunpack.bat
install-sh
libtool.m4
lt~obsolete.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
MAINTAINERS
Makefile.def
Makefile.in
Makefile.tpl
makefile.vms
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
README
README-maintainer-mode
setup.com
src-release.sh
symlink-tree
test-driver
ylwrap

		   README for GNU development tools

This directory contains various GNU compilers, assemblers, linkers, 
debuggers, etc., plus their support routines, definitions, and documentation.

If you are receiving this as part of a GDB release, see the file gdb/README.
If with a binutils release, see binutils/README;  if with a libg++ release,
see libg++/README, etc.  That'll give you info about this
package -- supported targets, how to use it, how to report bugs, etc.

It is now possible to automatically configure and build a variety of
tools with one command.  To build all of the tools contained herein,
run the ``configure'' script here, e.g.:

	./configure 
	make

To install them (by default in /usr/local/bin, /usr/local/lib, etc),
then do:
	make install

(If the configure script can't determine your type of computer, give it
the name as an argument, for instance ``./configure sun4''.  You can
use the script ``config.sub'' to test whether a name is recognized; if
it is, config.sub translates it to a triplet specifying CPU, vendor,
and OS.)

If you have more than one compiler on your system, it is often best to
explicitly set CC in the environment before running configure, and to
also set CC when running make.  For example (assuming sh/bash/ksh):

	CC=gcc ./configure
	make

A similar example using csh:

	setenv CC gcc
	./configure
	make

Much of the code and documentation enclosed is copyright by
the Free Software Foundation, Inc.  See the file COPYING or
COPYING.LIB in the various directories, for a description of the
GNU General Public License terms under which you can copy the files.

REPORTING BUGS: Again, see gdb/README, binutils/README, etc., for info
on where and how to report problems.