Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 649704 - sys-devel/gdb-8.1 with sys-libs/ncurses-6.1-r1 - gdb -tui: segmentation fault in has_colors_sp at .../ncurses/base/lib_color.c:822
Summary: sys-devel/gdb-8.1 with sys-libs/ncurses-6.1-r1 - gdb -tui: segmentation fault...
Status: RESOLVED DUPLICATE of bug 669096
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal with 1 vote (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: ncurses-6.1
  Show dependency tree
 
Reported: 2018-03-06 05:08 UTC by Dale Lukas Peterson
Modified: 2018-11-15 23:37 UTC (History)
4 users (show)

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


Attachments
gdb ncurses info (ncurses_gdb_info.txt,6.81 KB, text/plain)
2018-03-06 05:09 UTC, Dale Lukas Peterson
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dale Lukas Peterson 2018-03-06 05:08:22 UTC
[I] ~> gdb -tui
fish: “gdb -tui” terminated by signal SIGSEGV (Address boundary error)

I rebuilt gdd-8.1 and ncurses-6.1-r1 with -ggdb and and gdb on `gdb -tui`:

[I] ~> gdb --args gdb -tui
GNU gdb (Gentoo 8.1 p1) 8.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
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:
<https://bugs.gentoo.org/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from gdb...Reading symbols from /usr/lib/debug//usr/bin/gdb.debug...done.
done.
(gdb) run
Starting program: /usr/bin/gdb -tui
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
has_colors_sp (sp=sp@entry=0x5555560f1f70) at /usr/src/debug/sys-libs/ncurses-6.1-r1/ncurses-6.1/ncurses/base/lib_color.c:822
822			     || set_color_pair)) ? TRUE : FALSE);
(gdb) bt
#0  has_colors_sp (sp=sp@entry=0x5555560f1f70) at /usr/src/debug/sys-libs/ncurses-6.1-r1/ncurses-6.1/ncurses/base/lib_color.c:822
#1  0x00007ffff7318837 in _nc_setupscreen_sp (spp=spp@entry=0x7fffffffdfa8, slines=<optimized out>, scolumns=<optimized out>, output=output@entry=0x7ffff6434740 <_IO_2_1_stdout_>, filtered=<optimized out>, slk_format=slk_format@entry=0)
    at /usr/src/debug/sys-libs/ncurses-6.1-r1/ncurses-6.1/ncurses/base/lib_set_term.c:508
#2  0x00007ffff7313ece in newterm_sp (sp=<optimized out>, name=name@entry=0x0, ofp=ofp@entry=0x7ffff6434740 <_IO_2_1_stdout_>, ifp=ifp@entry=0x7ffff64339e0 <_IO_2_1_stdin_>)
    at /usr/src/debug/sys-libs/ncurses-6.1-r1/ncurses-6.1/ncurses/base/lib_newterm.c:222
#3  0x00007ffff7314358 in newterm (name=name@entry=0x0, ofp=0x7ffff6434740 <_IO_2_1_stdout_>, ifp=0x7ffff64339e0 <_IO_2_1_stdin_>) at /usr/src/debug/sys-libs/ncurses-6.1-r1/ncurses-6.1/ncurses/base/lib_newterm.c:355
#4  0x0000555555651835 in tui_enable () at tui/tui.c:427
#5  0x00005555557e1543 in captured_main_1 (context=<optimized out>) at main.c:960
#6  captured_main (data=<optimized out>) at main.c:1146
#7  gdb_main (args=<optimized out>) at main.c:1172
#8  0x00005555555eb10b in main (argc=<optimized out>, argv=<optimized out>) at gdb.c:32
(gdb) p set_color_pair
No symbol "set_color_pair" in current context.
(gdb) p code
$1 = 0
(gdb) p set_a_background
No symbol "set_a_background" in current context.
(gdb) up
#1  0x00007ffff7318837 in _nc_setupscreen_sp (spp=spp@entry=0x7fffffffdfa8, slines=<optimized out>, scolumns=<optimized out>, output=output@entry=0x7ffff6434740 <_IO_2_1_stdout_>, filtered=<optimized out>, slk_format=slk_format@entry=0)
    at /usr/src/debug/sys-libs/ncurses-6.1-r1/ncurses-6.1/ncurses/base/lib_set_term.c:508
508	    if (NCURSES_SP_NAME(has_colors) (NCURSES_SP_ARG)) {
(gdb) down
#0  has_colors_sp (sp=sp@entry=0x5555560f1f70) at /usr/src/debug/sys-libs/ncurses-6.1-r1/ncurses-6.1/ncurses/base/lib_color.c:822
822			     || set_color_pair)) ? TRUE : FALSE);
(gdb) info locals
No locals.

I'm not sure what the root cause is here, I guess I should recompile with -O0 so I can see locals. I'm also not sure whether this is a gdb issue or a ncurses issue.
Comment 1 Dale Lukas Peterson 2018-03-06 05:09:57 UTC
Created attachment 522482 [details]
gdb ncurses info
Comment 2 Alessandro Di Federico 2018-03-15 13:46:55 UTC
I've the same issue.
I tried to downgrade to =sys-libs/ncurses-6.0-r2 and everything works fine.
Comment 3 Jason Zaman gentoo-dev 2018-03-25 16:34:26 UTC
Interestingly i dont get this, but i do get a very very similar stacktrace when mutt segfaults.

mutt segfaults with both TERM=xterm-256color and =screen. any chance changing $TERM makes it work for you?
Comment 4 Dale Lukas Peterson 2018-03-25 16:49:04 UTC
I tried xterm-256color, screen, ansi, and unset. All result in a SIGSEV for me:

[I] luke@airwolf ~> echo $TERM
xterm-256color
[I] luke@airwolf ~> gdb -tui
fish: “gdb -tui” terminated by signal SIGSEGV (Address boundary error)
[I] luke@airwolf ~> set -x TERM screen
[I] luke@airwolf ~> echo $TERM
screen
[I] luke@airwolf ~> gdb -tui
fish: “gdb -tui” terminated by signal SIGSEGV (Address boundary error)
[I] luke@airwolf ~> set -x TERM ansi
[I] luke@airwolf ~> echo $TERM
ansi
[I] luke@airwolf ~> gdb -tui
fish: “gdb -tui” terminated by signal SIGSEGV (Address boundary error)
[I] luke@airwolf ~> set -e TERM
<W> fish: Could not set up terminal.
<W> fish: TERM environment variable not set.
<W> fish: Using fallback terminal type 'ansi'.
[I] luke@airwolf ~> echo $TERM

[I] luke@airwolf ~> gdb -tui
Cannot enable the TUI: error opening terminal [TERM=<unset>]
[I] luke@airwolf ~>
Comment 5 Dale Lukas Peterson 2018-03-25 16:49:48 UTC
Rather, all but unset result in SIGSEV; when unset tui mode doesn't work though.
Comment 6 Quentin Minster 2018-03-31 09:01:41 UTC
See https://bugs.gentoo.org/651552#c14 which applies to gdb too.
Comment 7 Andreas K. Hüttel gentoo-dev 2018-06-23 15:11:30 UTC
(In reply to Quentin Minster from comment #6)
> See https://bugs.gentoo.org/651552#c14 which applies to gdb too.

OK if I understand this correctly, with ncurses[tinfo] two incompatible libraries get linked to and mixed up. 

Easiest workaround should be building ncurses without the tinfo useflag (which I have here, and gdb-8.1-r1 works just fine).

This should be independent of gdb version by the way.
Comment 8 Tomáš "tpruzina" Pružina (amd64 [ex]AT) 2018-10-18 13:42:39 UTC
Same problem, (gdb gdb; run; C-x a):

(gdb) 
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7ec0350 in _nc_setupscreen_sp () from /lib64/libncursesw.so.6
(gdb) bt
#0  0x00007ffff7ec0350 in _nc_setupscreen_sp () from /lib64/libncursesw.so.6
#1  0x00007ffff7eba57e in newterm_sp () from /lib64/libncursesw.so.6
#2  0x00007ffff7ebaa08 in newterm () from /lib64/libncursesw.so.6
#3  0x00005555559e99c5 in tui_enable () at tui/tui.c:427
#4  0x00005555559e9c84 in tui_enable () at tui/tui.c:403
#5  tui_rl_switch_mode (notused1=<optimized out>, notused2=<optimized out>) at tui/tui.c:110
#6  0x00007ffff7f54d6e in _rl_dispatch_subseq () from /lib64/libreadline.so.7
#7  0x00007ffff7f557fa in _rl_dispatch_callback () from /lib64/libreadline.so.7
#8  0x00007ffff7f6cc97 in rl_callback_read_char () from /lib64/libreadline.so.7
#9  0x00005555557be76e in gdb_rl_callback_read_char_wrapper_noexcept () at event-top.c:175
#10 0x00005555557be7f9 in gdb_rl_callback_read_char_wrapper (client_data=<optimized out>) at event-top.c:191
#11 0x00005555557becb0 in stdin_event_handler (error=<optimized out>, client_data=0x555555f5d7f0) at event-top.c:511
#12 0x00005555557bd92d in gdb_wait_for_event (block=block@entry=1) at event-loop.c:859
#13 0x00005555557bdc33 in gdb_wait_for_event (block=1) at event-loop.c:755
#14 gdb_do_one_event () at event-loop.c:347
#15 0x00005555557bde99 in gdb_do_one_event () at event-loop.c:978
#16 start_event_loop () at event-loop.c:371
#17 0x0000555555873b7b in captured_command_loop () at main.c:330
#18 0x0000555555874c6d in captured_main (data=<optimized out>) at main.c:1173
#19 gdb_main (args=<optimized out>) at main.c:1189
#20 0x000055555564045b in main (argc=<optimized out>, argv=<optimized out>) at gdb.c:32

$TERM=rxvt-256color

Workaround:

mv /lib/libtinfo.so.6{,.backup}
cp /lib/libtinfo{w,}.so.6
Comment 9 Sergei Trofimovich gentoo-dev 2018-10-18 18:35:34 UTC
when gdb SIGSEGVs can you post output of:
    $ lddtree /usr/bin/gdb
just to make sure both -w and non-w libraries link into gdb.
Comment 10 grumpytetra 2018-11-15 15:57:10 UTC
quick note: I resolved this issue locally by rebuilding ncurses [-tinfo] and upgrading gdb from v8.1-r1 to v8.2-r1.

=================================================================
                        Package Settings
=================================================================

sys-devel/gdb-8.2-r1::gentoo was built with the following:
USE="client lzma multitarget python server xml -nls -test -vanilla" ABI_X86="(64)" PYTHON_SINGLE_TARGET="python3_6 -python2_7 -python3_4 -python3_5" PYTHON_TARGETS="python3_4 python3_6 -python2_7 -python3_5"


sys-libs/ncurses-6.1-r2::gentoo was built with the following:
USE="cxx gpm threads unicode -ada -debug -doc -minimal -profile -static-libs -test -tinfo -trace" ABI_X86="(64) -32 (-x32)"
Comment 11 Sergei Trofimovich gentoo-dev 2018-11-15 23:20:17 UTC

*** This bug has been marked as a duplicate of bug 669096 ***