NetBSD Problem Report #53296
From www@NetBSD.org Thu May 17 16:21:12 2018
Return-Path: <www@NetBSD.org>
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 919567A156
for <gnats-bugs@gnats.NetBSD.org>; Thu, 17 May 2018 16:21:12 +0000 (UTC)
Message-Id: <20180517162111.5B1807A1FB@mollari.NetBSD.org>
Date: Thu, 17 May 2018 16:21:11 +0000 (UTC)
From: tobiasu@tmux.org
Reply-To: tobiasu@tmux.org
To: gnats-bugs@NetBSD.org
Subject: vim is super-slow (hangs) on sparc64 / select issue
X-Send-Pr-Version: www-1.0
>Number: 53296
>Notify-List: dholland@netbsd.org, martin@netbsd.org, bsiegert@netbsd.org
>Category: pkg
>Synopsis: vim is super-slow (hangs) on sparc64 / select issue
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: morr
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu May 17 16:25:00 +0000 2018
>Closed-Date: Sat Sep 15 12:40:04 +0000 2018
>Last-Modified: Sat Sep 15 12:50:01 +0000 2018
>Originator: Tobias Ulmer
>Release: 8.99.17
>Organization:
>Environment:
NetBSD u60 8.99.17 NetBSD 8.99.17 (GENERIC) #5: Wed May 16 13:48:05 UTC 2018 root@u60:/usr/obj/sys/arch/sparc64/compile/GENERIC sparc64
>Description:
HW: Ultra 60 2x450mhz 2G, plenty fast for what I'm asking it to do.
vim /etc/fstab takes 10 or more seconds display the file.
Cursor movement 'hangs' (feels like using vim over a modem line on the other side of the world). Connection is over local ssh and vi works fine.
Had a look with ktrace. Vim is repeatedly calling select() (~1000+ times) with varying timeout less than 1s. select() returns either 0 or EINVAL.
Patched the kernel to see where EINVAL comes from. It's either because the input struct timeval's tv_usec is already negative or the conversion to timespec produces an integer overflow.
Example: sys___select50: tv={0, -18872}
tv_sec is always 0. tv_usec is suspiciously random.
Had a look into vim's os_unix.c. It's calling select() in RealWaitForChar(), passing in a timeout pointer tvp to a local struct timeval tv;
But no matter how hard I try, gdb insists the value of *tvp is {0, 0}. -O2, -O0 make no difference.
I've put in code to make it coredump when tv_usec is != 0 to no avail.
os_unix.c:
6229 if (tvp->tv_usec != 0)
6230 abort();
6231 ret = select(maxfd + 1, &rfds, &wfds, &efds, tvp);
6232 if (ret < 0)
6233 abort(); // this hits.
Anyone got an idea how to solve this mystery?
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: port-sparc64-maintainer->martin
Responsible-Changed-By: martin@NetBSD.org
Responsible-Changed-When: Thu, 17 May 2018 16:34:35 +0000
Responsible-Changed-Why:
Take
From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: port-sparc64/53296: vim is super-slow (hangs) on sparc64 /
select issue
Date: Fri, 18 May 2018 09:39:18 +0200
In userland:
[Switching to LWP 1 of process 842]
_select (nfds=<optimized out>, readfds=0xffffffffffffd010,
writefds=0xffffffffffffd030, exceptfds=0xffffffffffffd050,
tim50=0xffffffffffffd000)
and:
(gdb) p *tim50
$4 = {tv_sec = 0, tv_usec = 1078990848}
If I don't miscount, that is quite a lot of usec (needs to be < 1s).
Martin
Responsible-Changed-From-To: martin->pkg-manager
Responsible-Changed-By: martin@NetBSD.org
Responsible-Changed-When: Fri, 18 May 2018 11:43:46 +0000
Responsible-Changed-Why:
Not a sparc64 specific issue.
From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: pkg/53296: vim is super-slow (hangs) on sparc64 / select issue
Date: Fri, 18 May 2018 13:47:40 +0200
The source plays stupid tricks with the select declaration, see os_unix.c:
/*
* Some systems have a prototype for select() that has (int *) instead of
* (fd_set *), which is wrong. This define removes that prototype. We define
* our own prototype below.
* Don't use it for the Mac, it causes a warning for precompiled headers.
* TODO: use a configure check for precompiled headers?
*/
#if !defined(__APPLE__) && !defined(__TANDEM)
# define select select_declared_wrong
#endif
and then it does not include <sys/select.h>, thus missing the function
renaming on NetBSD. See brute force hack below for a possible fix.
Martin
--- src/os_unix.c.orig 2018-04-28 21:56:44.000000000 +0200
+++ src/os_unix.c 2018-05-18 13:41:00.874162825 +0200
@@ -25,8 +25,11 @@
* Don't use it for the Mac, it causes a warning for precompiled headers.
* TODO: use a configure check for precompiled headers?
*/
-#if !defined(__APPLE__) && !defined(__TANDEM)
+#if !defined(__APPLE__) && !defined(__TANDEM) && !defined(__NetBSD__)
# define select select_declared_wrong
+#else
+#include <sys/select.h>
+#define HAVE_SYS_SELECT 1
#endif
#include "vim.h"
@@ -77,7 +80,7 @@
# endif
#endif
-#if defined(HAVE_SELECT)
+#if defined(HAVE_SELECT) && !defined(HAVE_SYS_SELECT)
extern int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
#endif
From: David Holland <dholland-pbugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: pkg/53296: vim is super-slow (hangs) on sparc64 / select issue
Date: Wed, 6 Jun 2018 18:19:26 +0000
On Fri, May 18, 2018 at 11:50:01AM +0000, Martin Husemann wrote:
> The source plays stupid tricks with the select declaration, see os_unix.c:
> [...]
Please also report this upstream if you haven't as it's unlikely that
it fails only on netbsd.
--
David A. Holland
dholland@netbsd.org
State-Changed-From-To: open->feedback
State-Changed-By: bsiegert@NetBSD.org
State-Changed-When: Sun, 08 Jul 2018 10:34:40 +0000
State-Changed-Why:
Did anyone on the thread actually report this upstream?
Responsible-Changed-From-To: pkg-manager->morr
Responsible-Changed-By: bsiegert@NetBSD.org
Responsible-Changed-When: Sun, 08 Jul 2018 10:35:13 +0000
Responsible-Changed-Why:
Over to vim maintainer.
From: Tobias Ulmer <tobiasu@tmux.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: port-sparc64/53296: vim is super-slow (hangs) on sparc64 /
select issue
Date: Thu, 13 Sep 2018 14:01:50 +0200
This issue is fixed in vim 8.1.0371
https://github.com/vim/vim/commit/643b6140873e0e6f297df0cbca11bc1ea1f21925
State-Changed-From-To: feedback->closed
State-Changed-By: bsiegert@NetBSD.org
State-Changed-When: Sat, 15 Sep 2018 12:40:04 +0000
State-Changed-Why:
Updated vim to a fixed version. Thanks!
From: "Benny Siegert" <bsiegert@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/53296 CVS commit: pkgsrc/editors
Date: Sat, 15 Sep 2018 12:36:41 +0000
Module Name: pkgsrc
Committed By: bsiegert
Date: Sat Sep 15 12:36:41 UTC 2018
Modified Files:
pkgsrc/editors/vim-gtk2: Makefile
pkgsrc/editors/vim-gtk3: Makefile
pkgsrc/editors/vim-lang: PLIST
pkgsrc/editors/vim-share: Makefile PLIST distinfo version.mk
Log Message:
Update vim to 8.1.0390.
Among other minor changes, this correctly detects the argument types for
select, fixing PR port-sparc64/53296.
To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 pkgsrc/editors/vim-gtk2/Makefile
cvs rdiff -u -r1.9 -r1.10 pkgsrc/editors/vim-gtk3/Makefile
cvs rdiff -u -r1.23 -r1.24 pkgsrc/editors/vim-lang/PLIST
cvs rdiff -u -r1.49 -r1.50 pkgsrc/editors/vim-share/Makefile
cvs rdiff -u -r1.41 -r1.42 pkgsrc/editors/vim-share/PLIST
cvs rdiff -u -r1.176 -r1.177 pkgsrc/editors/vim-share/distinfo
cvs rdiff -u -r1.118 -r1.119 pkgsrc/editors/vim-share/version.mk
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.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.