Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 669096 - sys-devel/gdb-8.2: crashes on 'layout asm'
Summary: sys-devel/gdb-8.2: crashes on 'layout asm'
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Toolchain Maintainers
: 649704 669488 (view as bug list)
Depends on:
Reported: 2018-10-20 21:14 UTC by Michał Górny
Modified: 2019-11-19 23:30 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---

gdb-8.2-tinfow.patch (gdb-8.2-tinfow.patch,900 bytes, patch)
2018-10-21 11:19 UTC, Sergei Trofimovich
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-10-20 21:14:25 UTC
$ gdb
GNU gdb (Gentoo 8.2 p1) 8.2
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
Find the GDB manual and other documentation resources online at:

For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) layout asm
Segmentation fault (core dumped)

A quick 'bt' gives:
#0  0x00007ffff751f879 in termattrs_sp () from /lib64/
#1  0x00007ffff751cc10 in _nc_setupscreen_sp () from /lib64/
#2  0x00007ffff751828d in newterm_sp () from /lib64/
#3  0x00007ffff7518747 in newterm () from /lib64/
#4  0x0000555555679a5e in ?? ()
#5  0x0000555555681abd in ?? ()

Please let me know if you can reproduce it, or if I need to debug it further.
Comment 1 Sergei Trofimovich gentoo-dev 2018-10-20 21:58:39 UTC
Works here (likely by accident). I guess it's due to both

being linked in into final binary:
  $ lddtree /usr/bin/gdb
  /usr/bin/gdb (interpreter => /lib64/ => /lib64/ => /lib64/ => /lib64/

AFAIU both provide roughly the same set of symbols and thus are not supposed to be linked together.
Comment 2 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-10-20 22:10:34 UTC
Yeah, the following seems to work:

$ gdb

...but why does your readline link to ncurses?
Comment 3 Sergei Trofimovich gentoo-dev 2018-10-21 10:08:54 UTC
CC: base-system@

readline unconditionally pulls in from ebuild:

readline itself would be fine to use any of 'termcap', 'tinfo', 'ncurses', 'libc'. Whatever provides 'tgetent':

    BASH_CHECK_LIB_TERMCAP -> aclocal.m4

  [AC_CHECK_FUNC(tgetent, bash_cv_termcap_lib=libc,
    [AC_CHECK_LIB(termcap, tgetent, bash_cv_termcap_lib=libtermcap,
      [AC_CHECK_LIB(tinfo, tgetent, bash_cv_termcap_lib=libtinfo,
        [AC_CHECK_LIB(curses, tgetent, bash_cv_termcap_lib=libcurses,
            [AC_CHECK_LIB(ncurses, tgetent, bash_cv_termcap_lib=libncurses,
  if test $bash_cv_termcap_lib = gnutermcap && test -z "$prefer_curses"; then
  LDFLAGS="$LDFLAGS -L./lib/termcap"
  elif test $bash_cv_termcap_lib = libtermcap && test -z "$prefer_curses"; then
  elif test $bash_cv_termcap_lib = libtinfo; then
  elif test $bash_cv_termcap_lib = libncurses; then
  elif test $bash_cv_termcap_lib = libc; then

I think we need to add ncursesw here.

This gives us a few workarounds:
- force readline into ncursesw when available on ebuild side (would also need passing `pkg-config --cflags ncursesw` as well)
- force readline into -ltinfo depend (via sys-libs/ncurses[tinfo]) and avoid ncurses altogether.

I'd expect multiple readline users to already be affected.

$ lddtree /usr/lib64/python2.7/lib-dynload/
/usr/lib64/python2.7/lib-dynload/ (interpreter => None) => /lib64/ => /lib64/
... => /lib64/
Comment 4 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-10-21 10:48:29 UTC
Oh, so it's tinfo that makes readline not link to ncurses. Which is why it crashes for me.
Comment 5 Sergei Trofimovich gentoo-dev 2018-10-21 10:52:25 UTC

> - force readline into -ltinfo depend (via sys-libs/ncurses[tinfo]) and avoid ncurses altogether.

Actually, that does not work either. TIL there are both -ltinfo and -ltinfow.

Finally reproduced SIGSEGV as:

  # USE="tinfo" emerge -v1 ncurses readline sys-devel/gdb
  # lddtree /usr/bin/gdb
   /usr/bin/gdb (interpreter => /lib64/ => /lib64/ => /lib64/ => /lib64/ => /lib64/

This is also likely a gdb bug: it directly links against and (pulls in
Comment 6 Sergei Trofimovich gentoo-dev 2018-10-21 11:19:15 UTC
Created attachment 552084 [details, diff]

This makes SIGSEGV disappear. To avoid pulling in w/non-w libs libreadline will need to do the same.
Comment 7 Larry the Git Cow gentoo-dev 2018-10-21 16:27:44 UTC
The bug has been referenced in the following commit(s):

commit 63d949769e25176de0d879cbef2b7cd80348ad0f
Author:     Sergei Trofimovich <>
AuthorDate: 2018-10-21 16:26:47 +0000
Commit:     Sergei Trofimovich <>
CommitDate: 2018-10-21 16:27:36 +0000

    sys-devel/gdb: link against tinfow first, then tinfo. bug #669096
    In bug #669096 gdb was directly linked both
    to and
        $ lddtree /usr/bin/gdb
        /usr/bin/gdb (interpreter => /lib64/ => /lib64/ => /lib64/
   => /lib64/
    and caused gdb to SIGSEGV at start.
    Let's consistently link against *w libraries when both available.
    Note: the fix on it's own is not enough:
    - we don't pass include paths to ncursesw libraries
    - is still linked against in Gentoo
      and needs a separate fix.
    But it's enough to make immediate SIGSEGV to go away.
    Reported-by: Michał Górny
    Signed-off-by: Sergei Trofimovich <>
    Package-Manager: Portage-2.3.51, Repoman-2.3.11

 sys-devel/gdb/files/gdb-8.2-tinfow.patch |  44 ++++++
 sys-devel/gdb/gdb-8.2-r1.ebuild          | 261 +++++++++++++++++++++++++++++++
 2 files changed, 305 insertions(+)
Comment 8 Sergei Trofimovich gentoo-dev 2018-10-21 16:38:36 UTC
Filed bug #669214 to follow up on readline side.
Comment 9 Sergei Trofimovich gentoo-dev 2018-11-15 23:20:17 UTC
*** Bug 649704 has been marked as a duplicate of this bug. ***
Comment 10 Sergei Trofimovich gentoo-dev 2019-11-19 23:30:26 UTC
*** Bug 669488 has been marked as a duplicate of this bug. ***