NetBSD Problem Report #25317

Received: (qmail 12557 invoked by uid 605); 25 Apr 2004 18:04:24 -0000
Message-Id: <200404251804.i3PI41jk010309@apb.cequrux.com>
Date: Sun, 25 Apr 2004 20:04:01 +0200 (SAST)
From: apb@cequrux.com
Sender: gnats-bugs-owner@NetBSD.org
To: gnats-bugs@gnats.NetBSD.org
Subject: spurious "No more PTYs" from screen
X-Send-Pr-Version: 3.95

>Number:         25317
>Category:       pkg
>Synopsis:       spurious "No more PTYs" from screen
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    kim
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Apr 25 18:05:00 +0000 2004
>Closed-Date:    Wed Apr 13 00:16:18 +0000 2005
>Last-Modified:  Sat Sep 15 09:20:02 +0000 2012
>Originator:     Alan Barrett
>Release:        NetBSD 1.6ZK
>Organization:
Not much
>Environment:
System: NetBSD 1.6ZK
Architecture: i386
Machine: i386
>Description:
	screen-4.0.2 (from pkgsrc/misc/screen) sometimes
	reports "No more PTYs", even though there should
	be plenty of available PTYs, and other applications (including
	other instances of screen) are able to allocate PTYs.

>How-To-Repeat:
        Install screen.  Use it for several hours, opening and closing
        many windows.  I don't knopw exactly what causes the problem,
        and I have been unable to reproduce it on demand, but my normal
        usage pattern always triggers the problem after several hours.

>Fix:
        The patch in pkgsrc/misc/screen/patches/patch-aa seems to apply
        in the wrong place.  It adds a "#if defined(NetBSD)" section
        below the existing "#if defined(HAVE_OPENPTY)" in pty.c.  Moving
        the NetBSD block above the HAVE_OPENPTY block (instead of below
        it) seems to fix the problem (see the appended patch).  But
        perhaps we should just modify the "HAVE_OPENPTY" block without
        adding a NetBSD block?

Index: pkgsrc/misc/screen/patches/patch-aa
===================================================================
--- misc/screen/patches/patch-aa	15 Sep 2002 06:51:37 -0000	1.9
+++ misc/screen/patches/patch-aa	25 Apr 2004 17:41:12 -0000
@@ -1,8 +1,8 @@
 $NetBSD: patch-aa,v 1.9 2002/09/15 06:51:37 kim Exp $

---- pty.c.orig	Mon Feb 11 07:44:18 2002
-+++ pty.c	Mon Aug  5 19:58:48 2002
-@@ -318,6 +318,45 @@
+--- pty.c.orig	2003-09-08 16:26:18.000000000 +0200
++++ pty.c
+@@ -313,6 +313,45 @@ char **ttyn;

  /***************************************************************/

@@ -45,6 +45,6 @@
 +
 +/***************************************************************/
 +
- #ifndef PTY_DONE
+ #if defined(HAVE_OPENPTY) && !defined(PTY_DONE)
+ #define PTY_DONE
  int
- OpenPTY(ttyn)
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: pkg-manager->kim
Responsible-Changed-By: wiz@netbsd.org
Responsible-Changed-When: Mon, 14 Mar 2005 23:39:47 +0000
Responsible-Changed-Why:
Over to maintainer.


State-Changed-From-To: open->feedback
State-Changed-By: kim@netbsd.org
State-Changed-When: Tue, 29 Mar 2005 06:46:40 +0000
State-Changed-Why:

Hi Alan!

It is a bit difficult to understand the patch to a patch, i.e. I'm
having trouble figuring out which method you want to use.  Looking
at pty.c the only branch for "#ifndef PTY_DONE" is the last one that
defaults to BSD style PTY's.  It doesn't use openpty(3), so I don't
understand why you'd change that to require HAVE_OPENPTY defined.

The NetBSD block was added above so that the default case would not
be used on NetBSD, as it doesn't understand PTY naming on NetBSD.

I have a feeling that the "other" openpty(3) block got added in a
later version of screen(1), so most likely the NetBSD block is no
longer used.  However, I can't test this without an old enough
system, e.g. NetBSD 1.6.2.

About a month after you filed this PR, SVR4 style PTY's were added
to NetBSD.  That's what I am using, and I have not had any issues
with screen running even several months with 13-25 screens active.

If you still have an old enough system available, I'd like to have
you test which branch is selected in pty.c on it.  My approach would
be the following:

cd /usr/pkgsrc/misc/screen
make patch
vi work/screen-4.0.2/pty.c

Edit the file to insert #error statements with an identifying string
in each case, to verify which one is selected.  Then run "make" to
see where it stops in pty.c.

If it is using the first openpty(3) case, as I suspect it would, we
could analyze the problem more, by compering the two openpty(3) blocks.

If you have already upgraded to a more recent version of -current,
then I'd like to close this ticket (unless you still have the problem).

Regards,
+ Kim


From: Alan Barrett <apb@cequrux.com>
To: kim@netbsd.org
Cc: pkgsrc-bugs@netbsd.org, gnats-admin@netbsd.org
Subject: Re: pkg/25317
Date: Tue, 29 Mar 2005 20:45:46 +0200

 On Tue, 29 Mar 2005, kim@netbsd.org wrote:
 > Synopsis: spurious "No more PTYs" from screen
 > 
 > It is a bit difficult to understand the patch to a patch, i.e. I'm
 > having trouble figuring out which method you want to use.

 To properly see what I was talking about, you need to check out a
 version of pkgsrc from the date when I filed the PR.  Then apply the
 patch-to-a-patch, examine the resulting patch file to see how it would
 patch the original sources, apply the new patch file to the correct
 version of the original sources, examine the reulting patched source
 code.  And compare that with the resulting patched source code that you
 would get without using the patch-to-a-patch.

 > Looking at pty.c the only branch for "#ifndef PTY_DONE" is the last
 > one that defaults to BSD style PTY's.  It doesn't use openpty(3),
 > so I don't understand why you'd change that to require HAVE_OPENPTY
 > defined.

 Huh?  I didn't change that block at all.  I think you are looking at a
 version of pty.c as patched by revision 1.10 of patch-aa, whereas my PR
 was against revision 1.9 of patch-aa.

 > The NetBSD block was added above so that the default case would not
 > be used on NetBSD, as it doesn't understand PTY naming on NetBSD.

 The bug which I reported is that the "#if defined(NetBSD)" block was
 *below* the "#if defined(HAVE_OPENPTY)", whereas it should have been
 *above* the "#if defined(HAVE_OPENPTY)".  You say the NetBSD block
 was added above, I say that it *should have* been added above, and it
 probably was above in an older version of screen, but (with the versions
 of screen and patch-aa against which I filed the PR), the NetBSD block
 ended up being added below instead of above the HAVE_OPENPTY block.  The
 whole point of the PR was to report that problem.

 The reason that the patch used to apply in the wrong place is that the
 pty.c file contains many identical lines.  For example, the three-line
 sequence {blank line, comment line with many stars, blank line} appears
 many times.

 I believe that the current version of patch-aa will not apply in
 the wrong place, so the PR can be closed.  However, it's really
 disappointing that PRs that contain patches just get ignored for such a
 long time.  The longer my PRs get ignored, the more difficult it becomes
 to answer questions about them, and the more inclined I am to keep my
 patches to myself instead of submitting PRs.

 > I have a feeling that the "other" openpty(3) block got added in a
 > later version of screen(1), so most likely the NetBSD block is no
 > longer used.  However, I can't test this without an old enough
 > system, e.g. NetBSD 1.6.2.

 Yes, I think that's true.  I also no longer have a sufficiently
 old version of NetBSD.

 --apb (Alan Barrett)

State-Changed-From-To: feedback->closed
State-Changed-By: kim@netbsd.org
State-Changed-When: Wed, 13 Apr 2005 00:16:18 +0000
State-Changed-Why:
Unable to reproduce.

Alan -- I'm sorry that the PR was not looked in a timely manner.
Thanks for taking the time to submit it, and to answer my query.

Regards,
+ Kim


From: "Alan Barrett" <apb@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/25317 CVS commit: pkgsrc/misc/screen
Date: Sat, 15 Sep 2012 09:14:53 +0000

 Module Name:	pkgsrc
 Committed By:	apb
 Date:		Sat Sep 15 09:14:53 UTC 2012

 Modified Files:
 	pkgsrc/misc/screen: Makefile distinfo
 	pkgsrc/misc/screen/patches: patch-aa

 Log Message:
 Move the NetBSD-specific part of screen's pty.c to the right place.

 This commit changes patch-aa so that the patched version
 of pty.c contains:

     ... other OS-specific code
     ... NetBSD-specific openpty() code (from patch-aa)
     ... generic openpty() code
     ... last resort code

 instead of the previous:

     ... other OS-specific code
     ... generic openpty() code
     ... NetBSD-specific openpty() code (from patch-aa)
     ... last resort code

 History behind this problem:

 The NetBSD-specific openpty() code was added in revision 1.1
 of misc/screen/patches/patch-aa.  (See PR pkg/16901.)  At that
 time, pkgsrc used screen-3.9.11, and the upstream version of
 screen did not use openpty() at all.  The patch added an "#if
 defined(__NetBSD__)" block as the last OS-specific section in
 pty.c, which then had:

     ... other OS-specific code
     ... NetBSD-specific openpty() code (from patch-aa)
     ... last resort code

 In screen-3.9.15, upstream added code in pty.c to use openpty().
 This was imported to pkgsrc on 2003-03-15.  At that time, pkgsrc's
 patch-aa accidentally inserted the NetBSD-specific code below
 instead of above the new code, so the patched version of pty.c
 had:

     ... other OS-specific code
     ... generic openpty() code         (from upstream)
     ... NetBSD-specific openpty() code (from patch-aa)
     ... last resort code

 The above is obviously wrong because the generic openpty() code
 would be used instead of the NetBSD-specific code, assuming
 HAVE_OPENPTY was defined by the configure script.

 This problem was reported in PR pkg/25317, but the patch in the PR
 was not understood so it was not applied.

 This commit changes patch-aa so that the patched version of pty.c
 contains:

     ... other OS-specific code
     ... NetBSD-specific openpty() code (from patch-aa)
     ... generic openpty() code         (from upstream)
     ... last resort code

 However, it still doesn't work on NetBSD with ptyfs mounted.


 To generate a diff of this commit:
 cvs rdiff -u -r1.83 -r1.84 pkgsrc/misc/screen/Makefile
 cvs rdiff -u -r1.32 -r1.33 pkgsrc/misc/screen/distinfo
 cvs rdiff -u -r1.10 -r1.11 pkgsrc/misc/screen/patches/patch-aa

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

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.