Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Slackware This Forum is for the discussion of Slackware Linux.


  Search this Thread
Old 04-12-2021, 11:05 PM   #1
Registered: Mar 2020
Posts: 35

Rep: Reputation: Disabled
nvi segfaults in command edit and CFLAGS aren't set properly SlackBuild (-current)

nvi has a repeatable segfault in command history (cedit) mode. I haven't been able to track it down as to why yet. In part of trying to figure it out it looks like the SlackBuild also isn't setting the CFLAGS properly, as they don't seem to be picked up properly. I think it should be OPTFLAGS="$SLKCFLAGS" instead of CFLAGS, doing this I can at least see the SLKCFLAGS in the compiler invocations when make is called.

Back to the segfault

What I have in my ~/.nexrc :
set cedit=^V^V^V^I
(that is control-v control-v control-v control-tab if trying to enter it in while in nvi)
That is to set it so when I have the ex command prompt up I can hit tab and it will bring up the command history. This works as expected, but you can't do much while in the command history, nvi will segfault if you try to edit a command.

I had rebuilt the nvi package with some debugging flags enabled, and it looks like the ultimate point of the segfault is somewhere in the db48 library when it is doing a memmove. I had also rebuilt the db48 library with some debugging flags enabled, but this didn't help much. I tried building it with -fsanitize=address, but it basically bailed out at launch

Here is the stack trace from a stock nvi and stock db48 package:
#0  0x00007ffff7c1c241 in __memmove_sse2_unaligned_erms () from /lib64/
#1  0x00007ffff7e2b42c in __db_poff () from /lib64/
#2  0x00007ffff7d84702 in __bam_iitem () from /lib64/
#3  0x00007ffff7d8bb11 in ?? () from /lib64/
#4  0x00007ffff7e191b2 in __dbc_iput () from /lib64/
#5  0x00007ffff7e0e65a in __db_put () from /lib64/
#6  0x00007ffff7e25278 in __db_put_pp () from /lib64/
#7  0x00007ffff7f5e905 in db_set () from /usr/lib64/
#8  0x00007ffff7f721b7 in v_txt () from /usr/lib64/
#9  0x00007ffff7f6aa9e in v_ia () from /usr/lib64/
#10 0x00007ffff7f76683 in vi () from /usr/lib64/
#11 0x00007ffff7f5fa95 in editor () from /usr/lib64/
#12 0x0000000000403b6a in ?? ()
#13 0x00007ffff7b911ad in __libc_start_main () from /lib64/
#14 0x00000000004025aa in ?? ()
Does anyone have any ideas on how to investigate this further?

Last edited by kaott; 04-12-2021 at 11:17 PM.
Old 04-13-2021, 06:05 PM   #2
Registered: Dec 2020
Location: South Australia
Distribution: slackware64-current
Posts: 31

Rep: Reputation: Disabled
You're right on CFLAGS - dist/ in nvi is broken and overrides it with OPTFLAG. I think you still need to set CFLAGS to configure but could pass in OPTFLAG to make (OPTFLAG="$SLKCFLAGS" make), but ideally you should ask the author to fix the (or probably patch it in the slackbuild given it hasn't been updated in 14 years).

For debugging memory problems of c programs valgrind is the tool to use. It's somewhat complex but just running 'valgrind nvm' will get you something. For more useful output ensure the binaries and libraries are compiled in debug mode and not stripped (--enable-debug to configure does it for nvi).

valgrind might produce a lot of output so use --log-file=log as well. valgrind will mean it wont likely crash but just report the segfault and keep going.

nvi wont build on slackware64-current fwiw.
Old 04-13-2021, 06:23 PM   #3
Senior Member
Registered: Mar 2020
Posts: 2,227

Rep: Reputation: Disabled
FWIW, this is how I build nvi on CentOS 8 (part of my nvi.spec):
(cd build.unix
OPTFLAG="${CFLAGS:-%optflags}" \
ADDLDFLAGS="${LDFLAGS:-%__global_ldflags}" \
ac_cv_path_vi_cv_path_sendmail=/usr/sbin/sendmail \
vi_cv_revoke=no \
../dist/configure \
  --prefix=%{_prefix} --datadir=%{_datadir} --mandir=%{_mandir} \
  --disable-curses \
  --disable-shared --enable-static \
  --enable-widechar \
  --disable-threads \
  --without-x \
  --with-gnu-ld=yes \
%optflags and %__global_ldflags are Fedora-specific RPM macros defined thusly:
$ rpm -E %optflags
-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection
$ rpm -E %__global_ldflags
-Wl,-z,relro  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to set SLACKBUILD CFLAGS / CXXFLAGS / QMAKE C/CXX flags globally? qwxy Slackware 8 01-10-2018 06:20 AM
vim, nvi, and making them work together... kline Linux - Desktop 1 11-28-2010 07:59 AM
is there nvi [Keith Bostic's vi clone] for debian? kline Programming 1 12-23-2008 10:10 PM
nvi showing strange character JMJ_coder Linux - General 3 09-11-2008 06:44 PM
Where can I find nvi package mathewzhao Slackware 2 07-06-2006 08:12 AM > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 09:09 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration