Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault after ncurses update to 6.0 #568

Closed
PiotrZierhoffer opened this issue Feb 3, 2017 · 20 comments
Closed

Segfault after ncurses update to 6.0 #568

PiotrZierhoffer opened this issue Feb 3, 2017 · 20 comments

Comments

@PiotrZierhoffer
Copy link

The distro is gentoo. I had quite a huge update and now tig crashes.

I downloaded from the repo, my commit SHA is cef17fc.
I can rebuild probably any other dependency with more debug symbols if required.

#0  0x00007fd36c8e9896 in wchgat () from /lib64/libncurses.so.6
#1  0x000000000040fee4 in set_view_attr (type=LINE_PP_REFS, view=0x642940 <diff_view>) at src/draw.c:46
#2  draw_chars (view=view@entry=0x642940 <diff_view>, type=type@entry=LINE_PP_REFS, 
    string=string@entry=0x650080 <text> "Refs: [master], {origin/master}, {origin/HEAD}", 
    max_width=max_width@entry=118, use_tilde=use_tilde@entry=false, length=-1) at src/draw.c:73
#3  0x000000000041019c in draw_text_expanded (view=view@entry=0x642940 <diff_view>, type=LINE_PP_REFS, 
    string=string@entry=0x1b40500 "Refs: [master], {origin/master}, {origin/HEAD}", length=46, max_width=118, 
    use_tilde=use_tilde@entry=false) at src/draw.c:118
#4  0x0000000000410b77 in draw_textn (length=<optimized out>, 
    string=0x1b40500 "Refs: [master], {origin/master}, {origin/HEAD}", type=<optimized out>, 
    view=0x642940 <diff_view>) at src/draw.c:131
#5  view_column_draw (view=0x642940 <diff_view>, line=<optimized out>, lineno=1) at src/draw.c:552
#6  0x00000000004112bd in draw_view_line (view=view@entry=0x642940 <diff_view>, lineno=lineno@entry=1)
    at src/draw.c:633
#7  0x0000000000411645 in redraw_view_from (view=0x642940 <diff_view>, lineno=1) at src/draw.c:677
#8  0x000000000041798e in update_view (view=view@entry=0x642940 <diff_view>) at src/view.c:623
#9  0x0000000000414b1f in get_input (prompt_position=prompt_position@entry=-1, key=key@entry=0x7fffd7552310)
    at src/display.c:583
#10 0x000000000041176e in prompt_input (prompt=prompt@entry=0x42e0b2 "", input=input@entry=0x640c40 <incremental>)
    at src/prompt.c:49
#11 0x0000000000412c55 in read_prompt_incremental (prompt=prompt@entry=0x42e0b2 "", edit_mode=edit_mode@entry=false, 
    allow_empty=allow_empty@entry=false, handler=handler@entry=0x404250 <key_combo_handler>, 
    data=data@entry=0x7fffd7552770) at src/prompt.c:178
#12 0x000000000040464a in read_key_combo (keymap=<optimized out>) at src/tig.c:649
#13 0x000000000040381a in main (argc=<optimized out>, argv=<optimized out>) at src/tig.c:712
@jonas
Copy link
Owner

jonas commented Feb 6, 2017

There was one related issue where brew would build against one version of ncurses and link against another. Does ldd output look sane?

@PiotrZierhoffer
Copy link
Author

PiotrZierhoffer commented Feb 6, 2017

It might make sense! ldd looks fine, but I do have two ncurses 6.0 installations in two slots (gentoo-related concept). I'll try to remove one and reinstall everything.

@PiotrZierhoffer
Copy link
Author

Well, no luck. I uninstalled the duplicated version, reinstalled the correct one, rebuilt tig.

When I press enter I get a similar segfault.

Ldd output:

 [tig] (1) pzie:tig/output/bin/$ ldd tig
 	linux-vdso.so.1 (0x00007ffc9a58f000)
	libreadline.so.6 => /lib64/libreadline.so.6 (0x00007fa78a27d000)
	libncurses.so.6 => /lib64/libncurses.so.6 (0x00007fa78a054000)
	libncursesw.so.6 => /lib64/libncursesw.so.6 (0x00007fa789e15000)
	libtinfow.so.6 => /lib64/libtinfow.so.6 (0x00007fa789bdc000)
	libc.so.6 => /lib64/libc.so.6 (0x00007fa789843000)
	libtinfo.so.6 => /lib64/libtinfo.so.6 (0x00007fa78960a000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fa78a4c7000)

@jonas
Copy link
Owner

jonas commented Feb 6, 2017

It is weird that it links with both libncurses and libncursesw.

Are you building with configure or is this using the provided gentoo tig build configuration?

@PiotrZierhoffer
Copy link
Author

I do a fresh clone and configure. When I try to download & make, I get an error:

pzie:~/git/$ git clone https://github.com/jonas/tig.git tig-clean
Cloning into 'tig-clean'...
remote: Counting objects: 11725, done.
remote: Total 11725 (delta 0), reused 0 (delta 0), pack-reused 11724
Receiving objects: 100% (11725/11725), 4.93 MiB | 1.60 MiB/s, done.
Resolving deltas: 100% (8075/8075), done.
pzie:~/git/$ cd tig-clean
[tig-clean] pzie:pzie/git/tig-clean/$ make
        CC  src/tig.o
In file included from src/tig.c:16:0:
include/tig/tig.h:77:4: warning: #warning SysV or X/Open-compatible Curses installation is required. [-Wcpp]
 #  warning SysV or X/Open-compatible Curses installation is required.
    ^
include/tig/tig.h:78:4: warning: #warning Will assume Curses is found in default include and library path. [-Wcpp]
 #  warning Will assume Curses is found in default include and library path.
    ^
include/tig/tig.h:79:4: warning: #warning To fix any build issues please use autotools to configure Curses. [-Wcpp]
 #  warning To fix any build issues please use autotools to configure Curses.
    ^
include/tig/tig.h:80:4: warning: #warning See INSTALL.adoc file for instructions. [-Wcpp]
 #  warning See INSTALL.adoc file for instructions.
    ^
        CC  src/types.o
        CC  src/string.o
        CC  src/util.o
        CC  src/map.o
        CC  src/argv.o
        CC  src/io.o
        CC  src/refdb.o
       GEN  src/builtin-config.c
        CC  src/builtin-config.o
        CC  src/request.o
        CC  src/line.o
        CC  src/keys.o
        CC  src/repo.o
        CC  src/options.o
        CC  src/draw.o
        CC  src/prompt.o
        CC  src/display.o
        CC  src/view.o
        CC  src/search.o
        CC  src/parse.o
        CC  src/watch.o
        CC  src/pager.o
        CC  src/log.o
        CC  src/diff.o
        CC  src/help.o
        CC  src/tree.o
        CC  src/blob.o
        CC  src/blame.o
        CC  src/refs.o
        CC  src/status.o
        CC  src/stage.o
        CC  src/main.o
        CC  src/stash.o
        CC  src/grep.o
        CC  src/ui.o
        CC  src/graph.o
        CC  src/graph-v1.o
        CC  src/graph-v2.o
        CC  compat/hashtab.o
      LINK  src/tig
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/../../../../x86_64-pc-linux-gnu/bin/ld: src/display.o: undefined reference to symbol 'erasechar'
/lib64/libtinfo.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

After that I run make configure and ./configure --prefix=$mydir, output attached.

make; make install goes normally. Running tig gives me a segfault.

@PiotrZierhoffer
Copy link
Author

Oh, and the configure output:
configure.txt

@jonas
Copy link
Owner

jonas commented Feb 12, 2017

Can you also provide the generated config.make, thanks?

@PiotrZierhoffer
Copy link
Author

Sorry for a delay, had a week offline ;-)

Config.make attached. Also config.make.in, if it makes any difference. (renamed to txt because github)

config.make.in.txt
config.make.txt

@nertpinx
Copy link

I have the same problem, although my tig is not linked to both libraries:

$ ldd $(which tig)
	linux-vdso.so.1 (0x00007fffa6110000)
	libreadline.so.7 => /lib64/libreadline.so.7 (0x00007f06c53aa000)
	libncurses.so.6 => /lib64/libncurses.so.6 (0x00007f06c517c000)
	libtinfow.so.6 => /lib64/libtinfow.so.6 (0x00007f06c4f41000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f06c4b98000)
	libtinfo.so.6 => /lib64/libtinfo.so.6 (0x00007f06c495d000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007f06c4759000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f06c55ff000)

For some reason I cannot attach output of gdb, even in .txt file.

@PiotrZierhoffer
Copy link
Author

Apparently removing -lcurses from LDLIBS helps.

@nertpinx
Copy link

It does. Everything works perfectly. So it looks like there's default ncurses library added by mistake. Now it uses libncursesw instead and it Just Works (TM).

@jonas
Copy link
Owner

jonas commented Apr 1, 2017

@nertpinx are you also on Gentoo?

@nertpinx
Copy link

nertpinx commented Apr 1, 2017

Yes. With ncurses-5.9-r101 compiled with gpm, tinfo, unicode and ncurses-6.0-r1 compiled with cxx gpm threads tinfo unicode.

@mike-zueff
Copy link

mike-zueff commented Apr 4, 2017

Hey @nertpinx,

Please try to rebuild all ncurses slots with "tinfo" USE flag disabled, then rebuild tig with "unicode" USE flag enabled. In this case, tig works properly without any segfaults.

@nertpinx
Copy link

nertpinx commented Apr 4, 2017

@mike-zueff Thanks for the info. Rebuilding even just ncurses:5 without tinfo makes tig instantly work, so it is just an ncurses issue. It would also explain other tinfo problems I recall facing some time ago. Even if I rebuild it again with the same flags as before, it keeps working. I try to look for the problem in ncurses then. From my point of view, this is not a bug in tig in this case.

@jonas
Copy link
Owner

jonas commented Apr 4, 2017

OK, great that there's a work around. The issue could also be in the recent changes to the ncurses detection: 5eee021

@nertpinx
Copy link

nertpinx commented Apr 5, 2017

OK, so I have an update, unfortunately. On another machine I had to rebuild tig after installing ncurses without tinfo, that made tig linked with ncursesw instead of ncurses. However if I rebuild tig again, it links back with the previous library and segfaults when starting yet again.

For info, in case it helps, I'm attaching the outputs of ldd.

Working:

$ ldd $(which tig)
	linux-vdso.so.1 (0x00007ffdc18ed000)
	libreadline.so.7 => /lib64/libreadline.so.7 (0x00007f338f756000)
	libncursesw.so.6 => /lib64/libncursesw.so.6 (0x00007f338f515000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f338f16c000)
	libtinfo.so.6 => /lib64/libtinfo.so.6 (0x00007f338ef31000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007f338ed2d000)
	libtinfow.so.6 => /lib64/libtinfow.so.6 (0x00007f338eaf2000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f338f9ab000)

Non-working:

$ ldd $(which tig)
	linux-vdso.so.1 (0x00007ffc3a7fb000)
	libreadline.so.7 => /lib64/libreadline.so.7 (0x00007f40e13df000)
	libncurses.so.6 => /lib64/libncurses.so.6 (0x00007f40e11b1000)
	libtinfow.so.6 => /lib64/libtinfow.so.6 (0x00007f40e0f76000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f40e0bcd000)
	libtinfo.so.6 => /lib64/libtinfo.so.6 (0x00007f40e0992000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007f40e078e000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f40e1634000)

@radhermit
Copy link
Contributor

@gentoo users, just to note it can help to ping the pkg maintainer here or perhaps open a Gentoo bug as I could have fixed this months ago for you. 😄

I don't run any systems with split tinfo which is why I never noticed this until https://bugs.gentoo.org/show_bug.cgi?id=614590 was filed.

@jonas
Copy link
Owner

jonas commented Apr 11, 2017

Thanks @radhermit for the kind reminder and for providing a fix.

@undermink
Copy link

Got the same error with libncursesw.so.6.1 and pinged the pkg maintainer :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants