delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/09/19/05:10:00

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Wed, 19 Sep 2007 11:09:38 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Cc: Elliott Hughes <enh AT jessies DOT org>
Subject: Re: 1.5.24-2: zero-length write() and ioctl() on fd -1 cause crashes
Message-ID: <20070919090938.GA4380@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com, Elliott Hughes <enh AT jessies DOT org>
References: <DDD65EF5-1C72-4986-9B85-CE867B0AAE4F AT jessies DOT org>
Mime-Version: 1.0
In-Reply-To: <DDD65EF5-1C72-4986-9B85-CE867B0AAE4F@jessies.org>
User-Agent: Mutt/1.4.2.2i
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Elliot,

On Sep 18 11:54, Elliott Hughes wrote:
> http://software.jessies.org/terminator/ uses Cygwin to provide  
> Windows support, and it's been most useful. i just thought i'd  
> mention a couple of things that caused crashes in cygwin1.dll  
> 1.5.24-2 where that might not have been Cygwin's intent (in both  
> cases the application's skating on thin ice anyway).
> 
> first, if i do a zero-byte write(2) to a pty, i get a crash. POSIX  
> says the behavior in that situation is undefined. i haven't tested  
> with a regular file (where POSIX explicitly says that "write() will  
> return 0 and have no other results").
> 
> second, if i try to set the window size on fd -1, i get a crash:
> 
>     int fd = -1;
>     struct winsize size;
>     // set size.ws_col, size.ws_row, size.ws_xpixel, and  
> size.ws_ypixel...
>     if (ioctl(fd, TIOCSWINSZ, &size) < 0) {
> 
> my interpretation of POSIX is that i should get return value -1 and  
> errno set to EBADF in that case. i haven't tested with other invalid  
> file descriptors or other requests.
> 
> i haven't tested earlier versions of cygwin1.dll.
> 
> strangely, a quick look at the Cygwin source suggests that these  
> cases should be taken care of. "ioctl.cc"'s ioctl starts with a  
> cygheap_fdget, and check_iovec would appear to take care of the 0- 
> byte write case for write(2).

I've investigated both problems using small testcases and GDB and I
can't reproduce your observations.  In both cases Cygwin works fine,
returning 0 from write(2) when writing 0 bytes to anything (including
ptys), or, returning -1 from ioctl(2) when trying to set the window size
on an invalid fd.

These spurious crashes might hint to a problem in the application
itself.  For instance, they could be the result of a stack corruption at
some earlier point in the code.  Note that just because Cygwin crashes
but, say, Linux doesn't, that doesn't mean the application is right and
Cygwin is wrong.  The outcome of the application problem just shows
different results on different systems.

If, after investigation, you still think there's a Cygwin problem, we
would need some tiny testcase in plain C, which allows to reproduce the
problem with as little code as possible.


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019