From: Tom Tromey Date: Fri, 20 Jul 2018 03:10:09 +0000 (-0600) Subject: Fix crash with -D_GLIBCXX_DEBUG X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=463c08d160e55d6eaf0f9bc3729781ce90f4de3f;p=binutils-gdb.git Fix crash with -D_GLIBCXX_DEBUG I noticed a buildbot failure where gdb crashed in info-os.exp, when compiled with -D_GLIBCXX_DEBUG: (gdb) info os procgroups /usr/include/c++/7/bits/stl_algo.h:4834: Error: comparison doesn't meet irreflexive requirements, assert(!(a < a)). Objects involved in the operation: iterator::value_type "< operator type" { type = pid_pgid_entry; } The bug here is that pid_pgid_entry::operator< violates the C++ irreflexivity rule; that is, that an object cannot be less than itself. Tested locally by re-running info-os.exp. gdb/ChangeLog 2018-07-30 Tom Tromey * nat/linux-osdata.c (pid_pgid_entry::operator<): Fix irreflexivity violation. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 2cd7d6498b0..24ffeecda11 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2018-07-30 Tom Tromey + + * nat/linux-osdata.c (pid_pgid_entry::operator<): Fix + irreflexivity violation. + 2018-07-30 Tom Tromey * cli/cli-decode.c (lookup_cmd): Remove lint code. diff --git a/gdb/nat/linux-osdata.c b/gdb/nat/linux-osdata.c index 25e895df190..2323dcc878b 100644 --- a/gdb/nat/linux-osdata.c +++ b/gdb/nat/linux-osdata.c @@ -415,9 +415,11 @@ struct pid_pgid_entry /* Process group leaders always come first... */ if (this->is_leader ()) - return true; - - if (other.is_leader ()) + { + if (!other.is_leader ()) + return true; + } + else if (other.is_leader ()) return false; /* ...else sort by PID. */