Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 579826 - app-text/pinfo-0.6.10-r5: SIGSEGV through strip_info_suffix caused by pinfo-0.6.10-libc-basename.patch
Summary: app-text/pinfo-0.6.10-r5: SIGSEGV through strip_info_suffix caused by pinfo-0...
Status: RESOLVED WORKSFORME
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: Jeroen Roovers (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-13 11:43 UTC by Kamil Dudka
Modified: 2018-07-07 07:52 UTC (History)
1 user (show)

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


Attachments
pinfo-build.log.gz (pinfo-build.log.gz,6.96 KB, application/gzip)
2016-04-16 19:59 UTC, Kamil Dudka
Details
cave-info.gz (cave-info.gz,1.62 KB, application/gzip)
2016-04-17 08:51 UTC, Kamil Dudka
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kamil Dudka 2016-04-13 11:43:59 UTC
app-text/pinfo-0.6.10-r5:0::gentoo crashes on amd64 if a file name to open is given as parameter:

$ gdb -q --args pinfo ./doc/find.info
Reading symbols from pinfo...Reading symbols from /usr/lib64/debug//usr/bin/pinfo.debug...done.
done.
(gdb) run
Starting program: /usr/bin/pinfo ./doc/find.info
Przemek's Info Viewer v0.6.10

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7627bad in __strstr_sse2_unaligned () from /lib64/libc.so.6
(gdb) up
#1  0x00000000004061c2 in strip_info_suffix (file=file@entry=0xffffffffffffe186 <error: Cannot access memory at address 0xffffffffffffe186>) at filehandling_functions.c:1249
1249            if ( (found = strstr(file, suffix)) != NULL )
(gdb) 
#2  0x0000000000406229 in matchfile (buf=buf@entry=0x7fffffffdc38, name=name@entry=0x7fffffffe180 "./doc/find.info") at filehandling_functions.c:79
79              strip_info_suffix(bname);
(gdb) p name
$1 = 0x7fffffffe180 "./doc/find.info"
(gdb) p bname
$2 = 0xffffffffffffe186 <error: Cannot access memory at address 0xffffffffffffe186>
(gdb) 


The first 32 bits of the 64 bit pointer returned out of basename() are invalid because the prototype of basename() was not available at compile time (and the return type defaulted to int).

Adding the following line at the top of filehandling_functions.c fixes the bug:

#include <libgen.h>
Comment 1 SpanKY gentoo-dev 2016-04-16 05:00:36 UTC
string.h in glibc has provided a basename prototype for more than a decade, and that header is included by the source already.  i can't say why your system isn't working as you haven't provided any details about it: all bug reports really need emerge info and a full build log attached to them.
Comment 2 Kamil Dudka 2016-04-16 19:59:57 UTC
Created attachment 430860 [details]
pinfo-build.log.gz

(In reply to SpanKY from comment #1)
> string.h in glibc has provided a basename prototype for more than a decade,
> and that header is included by the source already.

It could be caused by using gcc-5.3.0 for build I guess.

> i can't say why your system isn't working

My system works as documented but pinfo does not.  See the basename(3) man page.

> as you haven't provided any details about it: all bug
> reports really need emerge info and a full build log attached to them.

I am attaching the build log.  emerge info would be confusing because I do not use emerge for build so its configuration could differ.
Comment 3 SpanKY gentoo-dev 2016-04-17 02:24:18 UTC
(In reply to Kamil Dudka from comment #2)

i'm using gcc-5.3 and it works fine.  your system is *not* working as documented.  the glibc manual shows that string.h is sufficient:
https://www.gnu.org/software/libc/manual/html_node/Finding-Tokens-in-a-String.html

basename() is provided by string.h.  if it isn't on your system, something is broken.  if you aren't using emerge then you know well enough that every PM has an equiv to `emerge --info` -- so provide it.

your build.log shows some misbehavior:
checking if ncurses supports extended chars... yes, with -D_XOPEN_SOURCE_EXTENDED
checking for wcwidth... with -D_XOPEN_SOURCE=600

those defines shouldn't be there.
Comment 4 Kamil Dudka 2016-04-17 08:51:29 UTC
Created attachment 430912 [details]
cave-info.gz

I am attaching the output of 'cave info pinfo'.  Note that the -ggdb flag was added by me while attempting to debug it.  The crash occurred without that flag, too.