NetBSD Problem Report #46190

From mm_lists@pulsar-zone.net  Wed Mar 14 03:15:14 2012
Return-Path: <mm_lists@pulsar-zone.net>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	by www.NetBSD.org (Postfix) with ESMTP id D583063B946
	for <gnats-bugs@gnats.NetBSD.org>; Wed, 14 Mar 2012 03:15:13 +0000 (UTC)
Message-Id: <201203140315.q2E3FIDC007088@ginseng.pulsar-zone.net>
Date: Tue, 13 Mar 2012 23:15:18 -0400
From: Matthew Mondor <mm_lists@pulsar-zone.net>
To: gnats-bugs@gnats.NetBSD.org
Subject: pkgsrc-2011Q4 - misc/rlwrap - Segfaults on amd64 - odd gdb results

>Number:         46190
>Category:       pkg
>Synopsis:       pkgsrc-2011Q4 - misc/rlwrap - Segfaults on amd64
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    leot
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Mar 14 03:20:00 +0000 2012
>Closed-Date:    Mon Nov 05 08:38:45 +0000 2018
>Last-Modified:  Mon Nov 05 08:38:45 +0000 2018
>Originator:     Matthew Mondor
>Release:        NetBSD 6.0_BETA
>Organization:
>Environment:
System: NetBSD ninja.xisop 6.0_BETA NetBSD 6.0_BETA (GENERIC_MM) #0: Tue Mar 13 20:34:43 EDT 2012 root@ninja.xisop:/usr/obj/sys/arch/amd64/compile/GENERIC_MM amd64
Architecture: x86_64
Machine: amd64
>Description:

I have a custom contacts application that was no longer launching, and
noticed that rlwrap was what was crashing.

Interestingly, if I try to debug it, I'm seeing something unexpected:

(gdb(gdb) bt
#0  0x000000000040a946 in mysavestring (string=0xfffffffff7b16800 <Address 0xfffffffff7b16800 out of bounds>) at string_utils.c:89
#1  0x0000000000408b9c in my_tgetstr (id=0x40ca2a "le") at term.c:48
#2  0x0000000000408dfd in init_terminal () at term.c:88
#3  0x00000000004048d4 in init_rlwrap () at main.c:417
#4  main (argc=<optimized out>, argv=0x7f7fffffd9e0) at main.c:117
(gdb) frame 1
#1  0x0000000000408b9c in my_tgetstr (id=0x40ca2a "le") at term.c:48
48        char *retval = stringcap ? mysavestring(stringcap) : NULL; 
(gdb) info locals
term_string_buf = 0x7f7ff7b16800 "\b"
tb = 0x7f7ff7b16802 "\261\367\177\177"
stringcap = 0xfffffffff7b16800 <Address 0xfffffffff7b16800 out of bounds>
retval = <optimized out>
__FUNCTION__ = "my_tgetstr"
(gdb) 
) bt
#0  0x000000000040a946 in mysavestring (string=0xfffffffff7b16800 <Address 0xfffffffff7b16800 out of bounds>) at string_utils.c:89
#1  0x0000000000408b9c in my_tgetstr (id=0x40ca2a "le") at term.c:48
#2  0x0000000000408dfd in init_terminal () at term.c:88
#3  0x00000000004048d4 in init_rlwrap () at main.c:417
#4  main (argc=<optimized out>, argv=0x7f7fffffd9e0) at main.c:117
(gdb) frame 1
#1  0x0000000000408b9c in my_tgetstr (id=0x40ca2a "le") at term.c:48
48        char *retval = stringcap ? mysavestring(stringcap) : NULL; 
(gdb) info locals
term_string_buf = 0x7f7ff7b16800 "\b"
tb = 0x7f7ff7b16802 "\261\367\177\177"
stringcap = 0xfffffffff7b16800 <Address 0xfffffffff7b16800 out of bounds>
retval = <optimized out>
__FUNCTION__ = "my_tgetstr"
(gdb) 

With the code being:

static char *my_tgetstr (char *id) {
  char *term_string_buf = (char *)mymalloc(2048), *tb = term_string_buf;
  char *stringcap = tgetstr(id, &tb); /*  rl_get_termcap(id) should also get string capability but doesn't. Why? */
  char *retval = stringcap ? mysavestring(stringcap) : NULL; 
  DPRINTF2(DEBUG_TERMIO, "tgetstr(\"%s\") = %s", id, (stringcap ?  mangle_string_for_debug_log(stringcap,20) : "NULL"));
  free(term_string_buf);
  return retval;
}

However, in a simple test:

#include <stdio.h>
#include <stdlib.h>
#include <termcap.h>

int     main(void);

int
main(void)
{
        char    *str = malloc(2048), *tb = str, *cap;

        str = tgetstr("le", &tb);
        (void) printf("%p\n", str);

        return 0;
}

$ ./tget
0x0


So I'm first wondering why the stringcap check succeeds if NULL is
returned.  Then, oddly enough the address of the buffer pointer is
passed to mysavestring() but with the first 32 bits set to 1:
0x7f7ff7b16800 becomes 0xfffffffff7b16800.

Could it be a toolchain bug?

Another thing which I didn't investigate is why the buffer is still set
to "\b" if tgetstr() returns NULL for "le".

>How-To-Repeat:
>Fix:

Unknown for now

>Release-Note:

>Audit-Trail:
From: Matthew Mondor <mm_lists@pulsar-zone.net>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/46190: pkgsrc-2011Q4 - misc/rlwrap - Segfaults on amd64 -
 odd gdb results
Date: Tue, 13 Mar 2012 23:25:18 -0400

 Obviously tget.c was buggy.  The following still yields the same
 results, though.

 #include <stdio.h>
 #include <stdlib.h>
 #include <termcap.h>

 int     main(void);

 int
 main(void)
 {
         char    str[2048], *tb = str, *cap;

         cap = tgetstr("le", &tb);
         (void) printf("cap = %p\n", cap);
         if (cap != NULL)
                 (void) printf("cap = %s\n", cap);
         (void) printf("tb = %p\n", tb);
         if (tb != NULL)
                 (void) printf("*tb = 0x%02x\n", *tb);

         return 0;
 }

 ninja$ ./tget
 cap = 0x0
 tb = 0x7f7fffffd220
 *tb = 0x05

 -- 
 Matt

From: Matthew Mondor <mm_lists@pulsar-zone.net>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/46190: pkgsrc-2011Q4 - misc/rlwrap - Segfaults on amd64 -
 odd gdb results
Date: Tue, 1 May 2012 04:39:13 -0400

 Someone else on IRC was having issues with BitchX on NetBSD/AMD64,
 and we both agreed it was very similar to this PR's issue.  While
 trying to come up with the smallest test case that could reproduce
 the problem, the following became obvious:

 On the amd64 ELF ABI, the C default return value (int) is 32-bit.
 Thus, calling any function working on pointers that is lacking a
 prototype can be fatal and result in corrupted pointers with the
 high 32-bit set to 0xffffffff.  I'm not sure if this could somehow
 be mitigated, but it might require breaking compatibility.

 Exemple:


 mymalloc.c:

 #include <stdlib.h>
 #include <err.h>

 void *
 my_malloc(size_t size)
 {
 	void *buf = malloc(size);

 	if (buf == NULL)
 		err(EXIT_FAILURE, "malloc(%ld)", size);

 	return buf;
 }


 main.c:

 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <err.h>

 int main(void);

 int
 main(void)
 {
 	char *str = (char *)my_malloc(2048);

 	(void)printf("%c %p\n", (str ? '1' : '0'), str);

 	if (str != NULL)
 		free(str);

 	return EXIT_SUCCESS;
 }


 Compile:

 cc -Wall -c -o mymalloc.o mymalloc.c
 cc -Wall -c -o main.o main.c
 cc -Wall -o test main.o mymalloc.o

 Test:

 ninja$ ./test 
 1 0xfffffffff7701800
 [1]   Segmentation fault (core dumped) ./test


 Conclusion:

 rlwrap is probably missing some prototype(s)/headers which it should
 include, and I'll post a further followup once I can patch it to
 work on amd64.


 -- 
 Matt

From: Matthew Mondor <mm_lists@pulsar-zone.net>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/46190: pkgsrc-2011Q4 - misc/rlwrap - Segfaults on amd64 -
 odd gdb results
Date: Tue, 1 May 2012 07:26:50 -0400

 --MP_/Rehqxbvrph4HXLP7j30kUbv
 Content-Type: text/plain; charset=US-ASCII
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline


 These make rlwrap work for me on NetBSD/amd64.  I'm not sure that the
 patch that adds the __NetBSD__ check is optimal, but it seems that
 configure.in changes would be required to properly detect termcap
 presence otherwise...

 -- 
 Matt

 --MP_/Rehqxbvrph4HXLP7j30kUbv
 Content-Type: text/plain
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment; filename=rlwrap-diff.txt

 Index: distinfo
 ===================================================================
 RCS file: /data/rsync/netbsd-cvs/pkgsrc/misc/rlwrap/distinfo,v
 retrieving revision 1.2
 diff -u -r1.2 distinfo
 --- distinfo	9 Jan 2008 13:40:38 -0000	1.2
 +++ distinfo	1 May 2012 11:20:17 -0000
 @@ -3,3 +3,5 @@
  SHA1 (rlwrap-0.30.tar.gz) = 26f3a6348710fee5e87f5274ddc29af8eaaf65d2
  RMD160 (rlwrap-0.30.tar.gz) = 23f19b9e98f61183fe719ee7a62db9d8ee2cf602
  Size (rlwrap-0.30.tar.gz) = 184037 bytes
 +SHA1 (patch-aa) = d4590dcb9b73b2ee778896eb8f6f36f8ef26a641
 +SHA1 (patch-ab) = 565021b2a1372c3a8ad77161c56ce94702097cb6

 --MP_/Rehqxbvrph4HXLP7j30kUbv
 Content-Type: text/plain
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment; filename=patch-aa

 If openpty(3) is in libutil, include util.h to avoid broken code on amd64

 --- src/ptytty.c.orig	2007-09-16 06:49:21.000000000 -0400
 +++ src/ptytty.c	2012-05-01 07:15:34.000000000 -0400
 @@ -38,6 +38,9 @@
  #ifdef HAVE_FCNTL_H
  # include <fcntl.h>
  #endif
 +#ifdef HAVE_LIBUTIL
 +# include <util.h>
 +#endif
  #ifdef HAVE_SYS_IOCTL_H
  # include <sys/ioctl.h>
  #endif

 --MP_/Rehqxbvrph4HXLP7j30kUbv
 Content-Type: text/plain
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment; filename=patch-ab

 I'm not sure this patch is optimal, configure script changes would
 be required to make it better.  If on NetBSD, include termcap.h to
 provide the required prototypes and avoid generating broken code
 on amd64.

 --- src/rlwrap.h.orig	2007-12-27 06:17:58.000000000 -0500
 +++ src/rlwrap.h	2012-05-01 07:10:39.000000000 -0400
 @@ -105,6 +105,10 @@ char *strchr(), *strrchr();
  #  include <util.h>
  #endif

 +#ifdef __NetBSD__
 +# include <termcap.h>
 +#endif
 +




 --MP_/Rehqxbvrph4HXLP7j30kUbv--

From: Matthew Mondor <mm_lists@pulsar-zone.net>
To: gnats-bugs@NetBSD.org
Cc: heinz@NetBSD.org
Subject: Re: pkg/46190: pkgsrc-2011Q4 - misc/rlwrap - Segfaults on amd64 -
 odd gdb results
Date: Wed, 2 May 2012 23:03:30 -0400

 --MP_/Ve4gyygiY.okwQxWipu+ueX
 Content-Type: text/plain; charset=US-ASCII
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline

 On Tue,  1 May 2012 11:30:10 +0000 (UTC)
 Matthew Mondor <mm_lists@pulsar-zone.net> wrote:

 >  These make rlwrap work for me on NetBSD/amd64.  I'm not sure that the
 >  patch that adds the __NetBSD__ check is optimal, but it seems that
 >  configure.in changes would be required to properly detect termcap
 >  presence otherwise...

 This is an attempt at upgrading to rlwrap-0.37 (applied against
 pkgsrc-current).  There remains one patch necessary for the
 openpty(3)-in-libutil issue, but the other such issue was already fixed
 upstream.  I also sent mail to the author for the libutil fix (patch-aa
 and patch-ab, so that hopefully rlwrap 0.38 will include these fixes).

 I'm not too sure what to do about the optional test perl filters, and
 added a patch to disable these for now...

 Thanks,
 -- 
 Matt

 --MP_/Ve4gyygiY.okwQxWipu+ueX
 Content-Type: text/plain
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment; filename=rlwrap-037-diff

 Index: Makefile
 ===================================================================
 RCS file: /data/rsync/netbsd-cvs/pkgsrc/misc/rlwrap/Makefile,v
 retrieving revision 1.4
 diff -u -r1.4 Makefile
 --- Makefile	20 May 2009 00:58:24 -0000	1.4
 +++ Makefile	3 May 2012 02:21:20 -0000
 @@ -1,7 +1,7 @@
  # $NetBSD: Makefile,v 1.4 2009/05/20 00:58:24 wiz Exp $
  #

 -DISTNAME=	rlwrap-0.30
 +DISTNAME=	rlwrap-0.37
  PKGREVISION=	1
  CATEGORIES=	misc
  MASTER_SITES=	http://utopia.knoware.nl/~hlub/uck/rlwrap/
 Index: PLIST
 ===================================================================
 RCS file: /data/rsync/netbsd-cvs/pkgsrc/misc/rlwrap/PLIST,v
 retrieving revision 1.2
 diff -u -r1.2 PLIST
 --- PLIST	14 Jun 2009 18:07:29 -0000	1.2
 +++ PLIST	3 May 2012 02:40:13 -0000
 @@ -1,6 +1,5 @@
  @comment $NetBSD: PLIST,v 1.2 2009/06/14 18:07:29 joerg Exp $
  bin/rlwrap
  man/man1/rlwrap.1
 -share/rlwrap/coqtop
 -share/rlwrap/ftp
 -share/rlwrap/testclient
 +share/rlwrap/completions/coqtop
 +share/rlwrap/completions/testclient
 Index: distinfo
 ===================================================================
 RCS file: /data/rsync/netbsd-cvs/pkgsrc/misc/rlwrap/distinfo,v
 retrieving revision 1.2
 diff -u -r1.2 distinfo
 --- distinfo	9 Jan 2008 13:40:38 -0000	1.2
 +++ distinfo	3 May 2012 02:44:54 -0000
 @@ -1,5 +1,8 @@
  $NetBSD: distinfo,v 1.2 2008/01/09 13:40:38 heinz Exp $

 -SHA1 (rlwrap-0.30.tar.gz) = 26f3a6348710fee5e87f5274ddc29af8eaaf65d2
 -RMD160 (rlwrap-0.30.tar.gz) = 23f19b9e98f61183fe719ee7a62db9d8ee2cf602
 -Size (rlwrap-0.30.tar.gz) = 184037 bytes
 +SHA1 (rlwrap-0.37.tar.gz) = c8fc5e7798a7c618a22583c56fa38d344700cc2f
 +RMD160 (rlwrap-0.37.tar.gz) = 4e229e8fed579002605919760b313651aa427870
 +Size (rlwrap-0.37.tar.gz) = 251438 bytes
 +SHA1 (patch-aa) = d4590dcb9b73b2ee778896eb8f6f36f8ef26a641
 +SHA1 (patch-ab) = d2f512d48bd71c695e9b4f3ca2328a8cf057438b
 +SHA1 (patch-ac) = 2839d8dbd5daf2833c1817a83c13cef854c3435f

 --MP_/Ve4gyygiY.okwQxWipu+ueX
 Content-Type: text/plain
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment; filename=patch-aa

 If openpty(3) is in libutil, include util.h to avoid broken code on amd64

 --- src/ptytty.c.orig	2007-09-16 06:49:21.000000000 -0400
 +++ src/ptytty.c	2012-05-01 07:15:34.000000000 -0400
 @@ -38,6 +38,9 @@
  #ifdef HAVE_FCNTL_H
  # include <fcntl.h>
  #endif
 +#ifdef HAVE_LIBUTIL
 +# include <util.h>
 +#endif
  #ifdef HAVE_SYS_IOCTL_H
  # include <sys/ioctl.h>
  #endif

 --MP_/Ve4gyygiY.okwQxWipu+ueX
 Content-Type: text/plain
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment; filename=patch-ab

 Broke with -Wimplicit-function-declaration -Wimplicit -Werror

 --- src/string_utils.c.orig	2012-05-02 22:12:11.000000000 -0400
 +++ src/string_utils.c	2012-05-02 22:13:04.000000000 -0400
 @@ -617,8 +617,9 @@ colourless_strlen(const char *str, char 
    int visible = TRUE;
    int column = 0;
    int length = strlen(str);
 -  char *p, *q, *copy_without_ignore_markers;
 -  
 +  const char *p;
 +  char *q, *copy_without_ignore_markers;
 +

    assert(termwidth >= 0);
    q = copy_without_ignore_markers = mymalloc(length + 1);

 --MP_/Ve4gyygiY.okwQxWipu+ueX
 Content-Type: text/plain
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment; filename=patch-ac

 According to README: filters are to test rlwrap, not to be practical

 --- Makefile.in.orig	2010-04-30 09:45:35.000000000 -0400
 +++ Makefile.in	2012-05-02 22:38:47.000000000 -0400
 @@ -228,17 +228,11 @@
  top_srcdir = @top_srcdir@
  EXTRA_DIST = BUGS COPYING TODO INSTALL README PLEA src/rlwrap.h src/redblack.h src/malloc_debug.h\
               src/completion.rb doc/rlwrap.man.in test/testclient test/testit\
 -             completions/testclient completions/coqtop\
 -             filters/README filters/RlwrapFilter.pm filters/RlwrapFilter.3pm filters/count_in_prompt filters/pipeto\
 -             filters/logger filters/null filters/unbackspace filters/pipeline filters/ftp_filter filters/history_format\
 -             filters/simple_macro filters/template filters/scrub_prompt filters/paint_prompt filters/censor_passwords filters/listing
 +             completions/testclient completions/coqtop

  TESTS = test/testit
 -SUBDIRS = doc src filters
 -nobase_pkgdata_DATA = completions/testclient completions/coqtop\
 -		       filters/README filters/RlwrapFilter.pm filters/RlwrapFilter.3pm filters/count_in_prompt filters/pipeto\
 -                       filters/logger filters/null filters/unbackspace filters/pipeline filters/ftp_filter filters/history_format\
 -                       filters/simple_macro filters/template filters/scrub_prompt filters/paint_prompt filters/censor_passwords filters/listing
 +SUBDIRS = doc src
 +nobase_pkgdata_DATA = completions/testclient completions/coqtop

  all: config.h
  	$(MAKE) $(AM_MAKEFLAGS) all-recursive
 @@ -851,7 +845,7 @@
  	rm -f *~ 

  install-data-hook:
 -	chmod a+x $(DESTDIR)$(pkgdatadir)/filters/* 
 +#	chmod a+x $(DESTDIR)$(pkgdatadir)/filters/* 

  # Tell versions [3.59,3.63) of GNU make to not export all variables.
  # Otherwise a system limit (for SysV at least) may be exceeded.

 --MP_/Ve4gyygiY.okwQxWipu+ueX--

From: Matthew Mondor <mm_lists@pulsar-zone.net>
To: gnats-bugs@NetBSD.org
Cc: heinz@NetBSD.org
Subject: Re: pkg/46190: pkgsrc-2011Q4 - misc/rlwrap - Segfaults on amd64 -
 odd gdb results
Date: Sat, 8 Dec 2012 04:19:46 -0500

 On Wed, 2 May 2012 23:03:30 -0400
 Matthew Mondor <mm_lists@pulsar-zone.net> wrote:

 > On Tue,  1 May 2012 11:30:10 +0000 (UTC)
 > Matthew Mondor <mm_lists@pulsar-zone.net> wrote:
 > 
 > >  These make rlwrap work for me on NetBSD/amd64.  I'm not sure that the
 > >  patch that adds the __NetBSD__ check is optimal, but it seems that
 > >  configure.in changes would be required to properly detect termcap
 > >  presence otherwise...
 > 
 > This is an attempt at upgrading to rlwrap-0.37 (applied against
 > pkgsrc-current).  There remains one patch necessary for the
 > openpty(3)-in-libutil issue, but the other such issue was already fixed
 > upstream.  I also sent mail to the author for the libutil fix (patch-aa
 > and patch-ab, so that hopefully rlwrap 0.38 will include these fixes).
 > 
 > I'm not too sure what to do about the optional test perl filters, and
 > added a patch to disable these for now...

 I see that rlwrap was recently updated to 0.37 on -current pkgsrc.
 However my suggested patches weren't added, so rlwrap still segfaults
 on amd64 because of the lacking libutil.h include.  If that fix was
 applied (patch-aa), this PR could be closed.

 Thanks,
 -- 
 Matt

From: Thomas Klausner <wiz@NetBSD.org>
To: NetBSD bugtracking <gnats-bugs@NetBSD.org>
Cc: 
Subject: Re: pkg/46190: pkgsrc-2011Q4 - misc/rlwrap - Segfaults on amd64 -
 odd gdb results
Date: Mon, 10 Dec 2012 00:35:09 +0100

 --PPYy/fEw/8QCHSq3
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline

 On Sat, Dec 08, 2012 at 09:20:07AM +0000, Matthew Mondor wrote:
 >  I see that rlwrap was recently updated to 0.37 on -current pkgsrc.
 >  However my suggested patches weren't added, so rlwrap still segfaults
 >  on amd64 because of the lacking libutil.h include.  If that fix was
 >  applied (patch-aa), this PR could be closed.

 I'm a bit confused by the existing checks in rlwrap.

 It checks for libutil and libutil.h. In the code, it checks for
 HAVE_LIBUTIL_H, HAVE_UTIL_H (rlwrap.c) and HAVE_LIBUTIL (ptytty.c, if
 we apply the patch you suggest). AFAICS, nothing can set HAVE_UTIL_H,
 so at least that check is just wrong.

 Can you please confirm that the attached diff fixes the problem you
 see? (it really should check for HAVE_UTIL_H, but configure doesn't
 support this currently.)

 Can you please discuss the weird HAVE_UTIL_H check with upstream?

 Thanks,
  Thomas

 --PPYy/fEw/8QCHSq3
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="rlwrap.diff"

 Index: distinfo
 ===================================================================
 RCS file: /cvsroot/pkgsrc/misc/rlwrap/distinfo,v
 retrieving revision 1.3
 diff -u -r1.3 distinfo
 --- distinfo	30 Sep 2012 22:10:42 -0000	1.3
 +++ distinfo	9 Dec 2012 23:34:26 -0000
 @@ -3,3 +3,4 @@
  SHA1 (rlwrap-0.37.tar.gz) = c8fc5e7798a7c618a22583c56fa38d344700cc2f
  RMD160 (rlwrap-0.37.tar.gz) = 4e229e8fed579002605919760b313651aa427870
  Size (rlwrap-0.37.tar.gz) = 251438 bytes
 +SHA1 (patch-src_ptytty.c) = c76ceaf2add30ae56c8c190a8ffcb3cb79c7e1f0
 Index: patches/patch-src_ptytty.c
 ===================================================================
 RCS file: patches/patch-src_ptytty.c
 diff -N patches/patch-src_ptytty.c
 --- /dev/null	1 Jan 1970 00:00:00 -0000
 +++ patches/patch-src_ptytty.c	9 Dec 2012 23:34:26 -0000
 @@ -0,0 +1,17 @@
 +$NetBSD$
 +
 +If openpty(3) is in libutil, include util.h to avoid broken code
 +on amd64.
 +
 +--- src/ptytty.c.orig	2010-05-01 08:21:11.000000000 +0000
 ++++ src/ptytty.c
 +@@ -32,6 +32,9 @@
 + #ifdef HAVE_UNISTD_H
 + # include <unistd.h>
 + #endif
 ++#ifdef HAVE_LIBUTIL
 ++# include <util.h>
 ++#endif
 + #if defined(HAVE_STRING_H)
 + # include <string.h>
 + #endif

 --PPYy/fEw/8QCHSq3--

Responsible-Changed-From-To: pkg-manager->leot
Responsible-Changed-By: leot@NetBSD.org
Responsible-Changed-When: Tue, 18 Sep 2018 13:46:39 +0000
Responsible-Changed-Why:
Take


State-Changed-From-To: open->feedback
State-Changed-By: leot@NetBSD.org
State-Changed-When: Tue, 18 Sep 2018 14:20:26 +0000
State-Changed-Why:
I was not able to reproduce the SIGSEGV but I have just committed a
patch for the missing <util.h> inclusion via:

 cvs rdiff -u -r1.19 -r1.20 pkgsrc/misc/rlwrap/Makefile
 cvs rdiff -u -r1.6 -r1.7 pkgsrc/misc/rlwrap/distinfo
 cvs rdiff -u -r0 -r1.1 pkgsrc/misc/rlwrap/patches/patch-configure.ac

Can you please let us known if it fixes the problem?


Thank you!


From: "Leonardo Taccari" <leot@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/46190 CVS commit: pkgsrc/misc/rlwrap
Date: Tue, 18 Sep 2018 14:17:26 +0000

 Module Name:	pkgsrc
 Committed By:	leot
 Date:		Tue Sep 18 14:17:26 UTC 2018

 Modified Files:
 	pkgsrc/misc/rlwrap: Makefile distinfo
 Added Files:
 	pkgsrc/misc/rlwrap/patches: patch-configure.ac

 Log Message:
 rlwrap: Properly include <util.h> for openpty(3)

 Previously on NetBSD and probably other system that has openpty(3)
 in util.h the compilation lead to a:

  ptytty.c: In function 'ptytty_get_pty':
  ptytty.c:72:7: warning: implicit declaration of function 'openpty' [-Wimplicit-function-declaration]
     if (openpty(&pfd, fd_tty, tty_name, NULL, NULL) != -1) {
         ^~~~~~~

 due a missing <util.h> inclusion.

 Add a patch for configure.ac (and auto* tools to USE_TOOLS) in
 order to address that.

 Originally reported by Matthew Mondor via PR pkg/46190 and thanks
 to Matthew and <wiz> for their analysis!


 To generate a diff of this commit:
 cvs rdiff -u -r1.19 -r1.20 pkgsrc/misc/rlwrap/Makefile
 cvs rdiff -u -r1.6 -r1.7 pkgsrc/misc/rlwrap/distinfo
 cvs rdiff -u -r0 -r1.1 pkgsrc/misc/rlwrap/patches/patch-configure.ac

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: feedback->closed
State-Changed-By: leot@NetBSD.org
State-Changed-When: Mon, 05 Nov 2018 08:38:45 +0000
State-Changed-Why:
Feedback timeout.

A possible patch that should fixes this issue was committed.
Feel free to append any information and/or open a new PR
if it is still problematic.

Thank you!


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.