NetBSD Problem Report #54343
From wiz@yt.nih.at Thu Jul 4 19:22:13 2019
Return-Path: <wiz@yt.nih.at>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 5D90B7A13E
for <gnats-bugs@gnats.NetBSD.org>; Thu, 4 Jul 2019 19:22:13 +0000 (UTC)
Message-Id: <20190704175749.AB8F32AC0E5@yt.nih.at>
Date: Thu, 4 Jul 2019 19:57:49 +0200 (CEST)
From: Thomas Klausner <wiz@NetBSD.org>
Reply-To: Thomas Klausner <wiz@NetBSD.org>
To: gnats-bugs@NetBSD.org
Subject: "man -k config | less" broken
X-Send-Pr-Version: 3.95
>Number: 54343
>Category: bin
>Synopsis: "man -k config | less" broken
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bin-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Jul 04 19:25:01 +0000 2019
>Closed-Date: Mon Aug 19 13:10:50 +0000 2019
>Last-Modified: Fri Jun 03 12:25:01 +0000 2022
>Originator: Thomas Klausner
>Release: NetBSD 8.99.47
>Organization:
Curiosity is the very basis of education and if you tell me that
curiosity killed the cat, I say only that the cat died nobly.
- Arnold Edinborough
>Environment:
Architecture: x86_64
Machine: amd64
>Description:
man -k config
spams the screen.
So I tried redirecting it through less, but then I get nothing.
I also tried
man -k config 2>&1 | less
because I thought it might be written to stderr, but that didn't work either.
>How-To-Repeat:
see above
>Fix:
I suggest so, yes.
>Release-Note:
>Audit-Trail:
From: Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com>
To: NetBSD GNATS <gnats-bugs@netbsd.org>
Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: bin/54343: "man -k config | less" broken
Date: Thu, 15 Aug 2019 13:50:26 +0530
On Fri, Jul 5, 2019 at 12:55 AM Thomas Klausner <wiz@netbsd.org> wrote:
>
> >Number: 54343
> >Category: bin
> >Synopsis: "man -k config | less" broken
> >Confidential: no
> >Severity: serious
> >Priority: medium
> >Responsible: bin-bug-people
> >State: open
> >Class: sw-bug
> >Submitter-Id: net
> >Arrival-Date: Thu Jul 04 19:25:01 +0000 2019
> >Originator: Thomas Klausner
> >Release: NetBSD 8.99.47
> >Organization:
> Curiosity is the very basis of education and if you tell me that
> curiosity killed the cat, I say only that the cat died nobly.
> - Arnold Edinborough
> >Environment:
> Architecture: x86_64
> Machine: amd64
> >Description:
> man -k config
>
> spams the screen.
> So I tried redirecting it through less, but then I get nothing.
>
> I also tried
> man -k config 2>&1 | less
> because I thought it might be written to stderr, but that didn't work either.
> >How-To-Repeat:
> see above
> >Fix:
> I suggest so, yes.
I tried to reproduce this on fresh VM (NetBSD 9.99.8 amd64) but it
works there. There were a couple of bugs (specifically when
redirecting the output to less) which I fixed a while back (in
revision 1.42 of apropos-utils.c). I think this should not be
happening anymore, could you confirm if it is still an issue and any
specific setup or steps to reproduce?
Regards
Abhinav
From: Thomas Klausner <wiz@NetBSD.org>
To: gnats-bugs@netbsd.org
Cc: Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com>
Subject: Re: bin/54343: "man -k config | less" broken
Date: Thu, 15 Aug 2019 10:27:53 +0200
On Thu, Aug 15, 2019 at 08:25:02AM +0000, Abhinav Upadhyay wrote:
> I tried to reproduce this on fresh VM (NetBSD 9.99.8 amd64) but it
> works there. There were a couple of bugs (specifically when
> redirecting the output to less) which I fixed a while back (in
> revision 1.42 of apropos-utils.c). I think this should not be
> happening anymore, could you confirm if it is still an issue and any
> specific setup or steps to reproduce?
I just tried and can still reproduce on 9.99.7/amd64 (native).
# echo $TERM
xterm-256color
# man -k config
... (lots of output) ...
# man -k config 2>&1 | less
(nothing)
#
What more information could be relevant?
Thomas
From: Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com>
To: NetBSD GNATS <gnats-bugs@netbsd.org>
Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org,
Thomas Klausner <wiz@netbsd.org>
Subject: Re: bin/54343: "man -k config | less" broken
Date: Thu, 15 Aug 2019 14:17:13 +0530
On Thu, Aug 15, 2019 at 2:00 PM Thomas Klausner <wiz@netbsd.org> wrote:
>
> The following reply was made to PR bin/54343; it has been noted by GNATS.
>
> From: Thomas Klausner <wiz@NetBSD.org>
> To: gnats-bugs@netbsd.org
> Cc: Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com>
> Subject: Re: bin/54343: "man -k config | less" broken
> Date: Thu, 15 Aug 2019 10:27:53 +0200
>
> On Thu, Aug 15, 2019 at 08:25:02AM +0000, Abhinav Upadhyay wrote:
> > I tried to reproduce this on fresh VM (NetBSD 9.99.8 amd64) but it
> > works there. There were a couple of bugs (specifically when
> > redirecting the output to less) which I fixed a while back (in
> > revision 1.42 of apropos-utils.c). I think this should not be
> > happening anymore, could you confirm if it is still an issue and any
> > specific setup or steps to reproduce?
>
> I just tried and can still reproduce on 9.99.7/amd64 (native).
>
> # echo $TERM
> xterm-256color
> # man -k config
> ... (lots of output) ...
> # man -k config 2>&1 | less
> (nothing)
> #
>
> What more information could be relevant?
That is weird. What if you try apropos config | less?
Also, just to be sure could you provide the output of ident `which
apropos` | grep apropos :)
Regards
Abhinav
From: Thomas Klausner <wiz@netbsd.org>
To: Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com>
Cc: NetBSD bugtracking <gnats-bugs@NetBSD.org>
Subject: Re: bin/54343: "man -k config | less" broken
Date: Thu, 15 Aug 2019 10:55:43 +0200
On Thu, Aug 15, 2019 at 02:17:13PM +0530, Abhinav Upadhyay wrote:
> That is weird. What if you try apropos config | less?
That's worse :)
# apropos config | less
zsh: segmentation fault (core dumped) apropos config |
zsh: done less
[New process 1]
Core was generated by `apropos'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00007d546d97d310 in strlen () from /usr/lib/libc.so.12
(gdb) bt
#0 0x00007d546d97d310 in strlen () from /usr/lib/libc.so.12
#1 0x00007d546d8bb131 in _strdup (str=0x0) at /usr/src/lib/libc/string/strdup.c:60
#2 0x00007d546e00f682 in estrdup (s=<optimized out>) at /usr/src/lib/libutil/efun.c:89
#3 0x0000000083a22d6e in ul_pager (s=<optimized out>, ul=0) at /usr/src/usr.sbin/makemandb/apropos-utils.c:877
#4 callback_pager (callback_args=0x7f7fff236890) at /usr/src/usr.sbin/makemandb/apropos-utils.c:955
#5 0x0000000083a23231 in execute_search_query (args=0x7f7fff236a40,
query=0x7d546f3b4008 "SELECT section, name, name_desc, machine, snippet(mandb, '', '', '...', -1, 40 ), rank_func(matchinfo(mandb, \"pclxn\")) AS rank FROM mandb WHERE name NOT IN ( SELECT target FROM mandb_links WHERE link="..., db=<optimized out>) at /usr/src/usr.sbin/makemandb/apropos-utils.c:721
#6 run_query_internal (db=<optimized out>, snippet_args=<optimized out>, args=0x7f7fff236a40) at /usr/src/usr.sbin/makemandb/apropos-utils.c:748
#7 0x0000000083a239c0 in run_query_pager (args=<optimized out>, db=<optimized out>) at /usr/src/usr.sbin/makemandb/apropos-utils.c:1032
#8 run_query (db=0x7d546f426008, fmt=<optimized out>, args=0x7f7fff236a40) at /usr/src/usr.sbin/makemandb/apropos-utils.c:1153
#9 0x0000000083a25851 in main (argc=<optimized out>, argv=<optimized out>) at /usr/src/usr.sbin/makemandb/apropos.c:248
(gdb)
> Also, just to be sure could you provide the output of ident `which
> apropos` | grep apropos :)
# ident /usr/bin/apropos| grep apropos
/usr/bin/apropos:
$NetBSD: apropos.c,v 1.24 2017/11/25 14:29:38 abhinav Exp $
$NetBSD: apropos-utils.c,v 1.45 2019/06/07 16:43:58 leot Exp $
Thomas
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/54343 CVS commit: src/usr.sbin/makemandb
Date: Thu, 15 Aug 2019 06:29:07 -0400
Module Name: src
Committed By: christos
Date: Thu Aug 15 10:29:07 UTC 2019
Modified Files:
src/usr.sbin/makemandb: apropos-utils.c
Log Message:
PR/54343: Prevent NULL pointers in callback strings; use "*?*" for now to
identify them.
To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/usr.sbin/makemandb/apropos-utils.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: Thomas Klausner <wiz@NetBSD.org>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: PR/54343 CVS commit: src/usr.sbin/makemandb
Date: Sun, 18 Aug 2019 10:23:53 +0200
On Thu, Aug 15, 2019 at 10:30:02AM +0000, Christos Zoulas wrote:
> Module Name: src
> Committed By: christos
> Date: Thu Aug 15 10:29:07 UTC 2019
>
> Modified Files:
> src/usr.sbin/makemandb: apropos-utils.c
>
> Log Message:
> PR/54343: Prevent NULL pointers in callback strings; use "*?*" for now to
> identify them.
After this commit, the output is:
...
*?*/sd (4) SCSI and ATAPI disk driver
...to partition the disk into a BIOS level partition. This allows sharing the disk with other operating systems. The following config 1 options may be applied to SCSI disks as well as to other disks. SDRETRIES Set the number of...
...
where I have the "*?*/" prefix for all matches (both with and without
"|less"). What should be there?
But the core dump is gone.
Thomas
From: "Abhinav Upadhyay" <abhinav@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/54343 CVS commit: src/usr.sbin/makemandb
Date: Sun, 18 Aug 2019 09:14:30 +0000
Module Name: src
Committed By: abhinav
Date: Sun Aug 18 09:14:30 UTC 2019
Modified Files:
src/usr.sbin/makemandb: apropos-utils.c
Log Message:
PR bin/54343: We want the callback_args.machine to be NULL if it is not present in the DB.
The previous commit fixed the problem of allowing apropos to not crash and
produce output even if the database is missing values for certain mandatory
fields, such as name, section etc. Normally we don't expect those values
to be missing in the database but in case of parsing errors it can happen.
However, the machine architecture is an optional field since not all man pages
are hardware specific so that should be allowed to be set to NULL if not
present in the database.
To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/usr.sbin/makemandb/apropos-utils.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com>
To: NetBSD GNATS <gnats-bugs@netbsd.org>
Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org,
Thomas Klausner <wiz@netbsd.org>
Subject: Re: PR/54343 CVS commit: src/usr.sbin/makemandb
Date: Sun, 18 Aug 2019 14:56:01 +0530
On Sun, Aug 18, 2019 at 1:55 PM Thomas Klausner <wiz@netbsd.org> wrote:
>
> The following reply was made to PR bin/54343; it has been noted by GNATS.
>
> From: Thomas Klausner <wiz@NetBSD.org>
> To: gnats-bugs@netbsd.org
> Cc:
> Subject: Re: PR/54343 CVS commit: src/usr.sbin/makemandb
> Date: Sun, 18 Aug 2019 10:23:53 +0200
>
> On Thu, Aug 15, 2019 at 10:30:02AM +0000, Christos Zoulas wrote:
> > Module Name: src
> > Committed By: christos
> > Date: Thu Aug 15 10:29:07 UTC 2019
> >
> > Modified Files:
> > src/usr.sbin/makemandb: apropos-utils.c
> >
> > Log Message:
> > PR/54343: Prevent NULL pointers in callback strings; use "*?*" for now to
> > identify them.
>
> After this commit, the output is:
>
> ...
> *?*/sd (4) SCSI and ATAPI disk driver
> ...to partition the disk into a BIOS level partition. This allows sharing the disk with other operating systems. The following config 1 options may be applied to SCSI disks as well as to other disks. SDRETRIES Set the number of...
> ...
>
> where I have the "*?*/" prefix for all matches (both with and without
> "|less"). What should be there?
It was supposed to be the machine architecture for which the man page
was written, since not all man pages have it, the *?* prefix was being
output - I just fixed it.
> But the core dump is gone.
Yes (thanks Christos). Looking at the core dump it seems that
makemandb failed to parse the section number of some man page and
therefore when reading it from the database it was NULL, thus the
crash. Without looking at the man page I am not really sure if it is a
bug in the man page or makemandb. With Christos' commit apropos will
not crash anymore and it should be easy to find which man page is
missing the section number. If you think that the man page is correct
and makemandb should have been able to parse the section, let me know.
Regards
Abhinav
State-Changed-From-To: open->closed
State-Changed-By: wiz@NetBSD.org
State-Changed-When: Mon, 19 Aug 2019 13:10:50 +0000
State-Changed-Why:
Thank you, the last commits fixed the issue. I have a couple man pages to fix now :)
From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/54343 CVS commit: [netbsd-9] src/usr.sbin/makemandb
Date: Fri, 3 Jun 2022 12:25:14 +0000
Module Name: src
Committed By: martin
Date: Fri Jun 3 12:25:14 UTC 2022
Modified Files:
src/usr.sbin/makemandb [netbsd-9]: apropos-utils.c apropos.1 apropos.c
Log Message:
Pull up following revision(s) (requested by gutteridge in ticket #1461):
usr.sbin/makemandb/apropos.1: revision 1.19
usr.sbin/makemandb/apropos.c: revision 1.25
usr.sbin/makemandb/apropos.c: revision 1.26
usr.sbin/makemandb/apropos.1: revision 1.20
usr.sbin/makemandb/apropos.1: revision 1.21
usr.sbin/makemandb/apropos.1: revision 1.22
usr.sbin/makemandb/apropos.1: revision 1.23
usr.sbin/makemandb/apropos-utils.c: revision 1.46
usr.sbin/makemandb/apropos-utils.c: revision 1.47
usr.sbin/makemandb/apropos-utils.c: revision 1.49
PR/54343: Prevent NULL pointers in callback strings; use "*?*" for now to
identify them.
PR bin/54343: We want the callback_args.machine to be NULL if it is not
present in the DB.
The previous commit fixed the problem of allowing apropos to not crash and
produce output even if the database is missing values for certain mandatory
fields, such as name, section etc. Normally we don't expect those values
to be missing in the database but in case of parsing errors it can happen.
However, the machine architecture is an optional field since not all man pages
are hardware specific so that should be allowed to be set to NULL if not
present in the database.
apropos.c: fix pager functionality
Issue reported by Rocky Hotas on NetBSD-Users, patch input from RVP on
same, adjustments by me.
apropos.1: document the PAGER environment variable
apropos(1): use proper -width
apropos(1): use proper -width for the list of options too
apropos(1): Tweak the description of -1, ... -9, and -s
-s is not for compatibility only, because section names can be
anything. E.g. we have 3lua and 9lua in base. We have rudiments of
3f (for FORTRAN libs). Some packages in pkgsrc also use suffixed 1
and 3 sections.
apropos(1): Use the official spelling for "SQLite".
While here, use .Bx to refer to 3BSD.
apropos(1): improve error handling in edge cases
Patch from RVP on NetBSD-Users, with an additional comment tweak by me.
Summary from RVP:
1. Ignore SIGPIPE so that we're not killed in the middle of some
DB operation by a botched $PAGER:
$ env PAGER=3D/non-existent apropos -p ...
2. Return proper exit status in case of write errors:
$ apropos ... >/dev/full || echo fail
To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.45.2.1 src/usr.sbin/makemandb/apropos-utils.c
cvs rdiff -u -r1.18 -r1.18.18.1 src/usr.sbin/makemandb/apropos.1
cvs rdiff -u -r1.24 -r1.24.6.1 src/usr.sbin/makemandb/apropos.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.