pkgsrc-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: makewhatis(8) (from textproc/mandoc) fails with SIGSEGV
Hello Paul,
Paul Goyette writes:
> With a recently-rebuilt mandoc package, and a NetBSD-8.99.22 amd64 host,
> I am seeing makewhatis(8) aborting with SIGSEGV. I've tried to figure
> out what's going on, but have not succeeded. The stack backtrace in the
> core file is unhelpful:
> [...]
Trying to recompile it with `env CFLAGS=-g INSTALL_UNSTRIPPED=yes
make install' and then:
% /usr/pkg/sbin/makewhatis -n
Segmentation fault (core dumped)
Exit 139
...but according the .core the problem doesn't seem immediate!
| % gdb -core makewhatis.core /usr/pkg/sbin/makewhatis
| Reading symbols from /usr/pkg/sbin/makewhatis...done.
| [New process 1]
| Core was generated by `makewhatis'.
| Program terminated with signal SIGSEGV, Segmentation fault.
| #0 0x000000000041cc02 in manpath_add (dirs=dirs@entry=0x7f7ffffe1cd0, dir=0x7f7ffffe1c00 "/usr/share/man", complain=complain@entry=0)
| at manpath.c:147
| 147 dirs->paths[dirs->sz++] = mandoc_strdup(cp);
| (gdb) bt
| #0 0x000000000041cc02 in manpath_add (dirs=dirs@entry=0x7f7ffffe1cd0, dir=0x7f7ffffe1c00 "/usr/share/man", complain=complain@entry=0)
| at manpath.c:147
| #1 0x000000000041cc45 in manpath_parseline (dirs=dirs@entry=0x7f7ffffe1cd0, path=path@entry=0x7f7ffffe1c00 "/usr/share/man",
| complain=complain@entry=0) at manpath.c:113
| #2 0x000000000041d33f in manconf_file (conf=conf@entry=0x7f7ffffe1c90, file=file@entry=0x4448c5 "/etc/man.conf") at manpath.c:228
| #3 0x000000000041d470 in manconf_parse (conf=conf@entry=0x7f7ffffe1c90, file=0x4448c5 "/etc/man.conf", file@entry=0x0,
| defp=<optimized out>, defp@entry=0x0, auxp=auxp@entry=0x0) at manpath.c:76
| #4 0x000000000041bea0 in mandocdb (argc=0, argc@entry=2, argv=<optimized out>, argv@entry=0x7f7ffffe1f80) at mandocdb.c:478
| #5 0x000000000043b8dd in main (argc=2, argv=0x7f7ffffe1f80) at main.c:157
| (gdb) l
| 142 }
| 143
| 144 dirs->paths = mandoc_reallocarray(dirs->paths,
| 145 dirs->sz + 1, sizeof(char *));
| 146
| 147 dirs->paths[dirs->sz++] = mandoc_strdup(cp);
| 148 }
| 149
| 150 void
| 151 manconf_free(struct manconf *conf)
| (gdb) p dirs->paths
| $1 = (char **) 0xfffffffff210b4e8
| (gdb) p dirs->paths[0]
| Cannot access memory at address 0xfffffffff210b4e8
| (gdb) p dirs->sz
| $2 = 1
| (gdb) p dirs->paths[1]
| Cannot access memory at address 0xfffffffff210b4f0
It seems that mandoc_reallocarray() (if it calls reallocarray(3))
have not realloc-ated!
Giving a look at the compiler warnings seem to shed some light!:
| mandoc_aux.c: In function 'mandoc_reallocarray':
| mandoc_aux.c:83:8: warning: implicit declaration of function 'reallocarray' [-Wimplicit-function-declaration]
| ptr = reallocarray(ptr, num, size);
| ^~~~~~~~~~~~
Whoops! This is why (IIRC) since NetBSD 8.0 programs that uses
reallocarray(3) needs to be compiled with -D_OPENBSD_SOURCE.
The attached patch seems to fix this problem and after running the
`test' target all tests are now passed.
Paul, can you please try it and let us know if it fixes the problem?
Thank you!
mandoc: Add -D_OPENBSD_SOURCE to CFLAGS on NetBSD
Uses both strtonum(3) and reallocarray(3).
Bump PKGREVISION
Index: Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/textproc/mandoc/Makefile,v
retrieving revision 1.8
diff -u -p -r1.8 Makefile
--- Makefile 22 Aug 2018 09:46:47 -0000 1.8
+++ Makefile 10 Oct 2018 23:14:51 -0000
@@ -1,7 +1,7 @@
# $NetBSD: Makefile,v 1.8 2018/08/22 09:46:47 wiz Exp $
DISTNAME= mandoc-1.14.4
-PKGREVISION= 1
+PKGREVISION= 2
CATEGORIES= textproc devel
MASTER_SITES= http://mdocml.bsd.lv/snapshots/
@@ -18,6 +18,8 @@ SUBST_FILES.roff= mandoc.1 mandoc.3
SUBST_FILES.roff+= eqn.7 man.7 mdoc.7 tbl.7
SUBST_SED.roff= -e 's,Xr roff,Xr mandoc-roff,g'
+CFLAGS.NetBSD+= -D_OPENBSD_SOURCE
+
# test needs perl
USE_TOOLS+= perl:build
TEST_TARGET= regress
Home |
Main Index |
Thread Index |
Old Index