public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org>
To: cygwin-cvs@sourceware.org
Subject: [newlib-cygwin] Cygwin: pty: setup new pty on opening the master, not in constructor
Date: Wed,  9 Sep 2020 21:44:54 +0000 (GMT)	[thread overview]
Message-ID: <20200909214454.2BFB1385041C@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=09738c30627c20770d2a1cfa33aaf233bb77d035

commit 09738c30627c20770d2a1cfa33aaf233bb77d035
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Wed Sep 9 22:50:11 2020 +0200

    Cygwin: pty: setup new pty on opening the master, not in constructor
    
    Setting up the pty in the master constructor ends up creating a new pty
    on every stat(2) call on /dev/ptmx.  Only do this when actually opening
    the device, not when using the device class in another, non-opening
    context.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/fhandler_tty.cc | 7 ++-----
 winsup/cygwin/release/3.2.0   | 3 +++
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index 16d4a99f4..37d033bbe 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -1470,17 +1470,14 @@ fhandler_pty_master::fhandler_pty_master (int unit)
 {
   if (unit >= 0)
     dev ().parse (DEV_PTYM_MAJOR, unit);
-  else if (!setup ())
-    {
-      dev ().parse (FH_ERROR);
-      return;
-    }
   set_name ("/dev/ptmx");
 }
 
 int
 fhandler_pty_master::open (int flags, mode_t)
 {
+  if (!setup ())
+      return 0;
   set_open_status ();
   dwProcessId = GetCurrentProcessId ();
   return 1;
diff --git a/winsup/cygwin/release/3.2.0 b/winsup/cygwin/release/3.2.0
index 57d6d5147..11de87dbc 100644
--- a/winsup/cygwin/release/3.2.0
+++ b/winsup/cygwin/release/3.2.0
@@ -36,3 +36,6 @@ Bug Fixes
 
 - Fix assertion failure on an invalid path under /proc/<pid>/fd/.
   Addresses: https://cygwin.com/pipermail/cygwin/2020-September/246160.html
+
+- Fix crash on stat(2)'ing /dev/ptmx on 32 bit
+  Addresses: https://cygwin.com/pipermail/cygwin/2020-September/246218.html


                 reply	other threads:[~2020-09-09 21:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200909214454.2BFB1385041C@sourceware.org \
    --to=corinna@sourceware.org \
    --cc=cygwin-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).