delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/03/16/14:21:08

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
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
Date: Wed, 16 Mar 2005 14:20:56 -0500
From: Christopher Faylor <cgf-no-personal-reply-please AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: autossh crash with 20050314 and earlier cygwin1.dll
Message-ID: <20050316192056.GB20987@trixie.casa.cgf.cx>
Reply-To: cygwin AT cygwin DOT com
References: <MPG DOT 1ca231f3e2e4ec239896d2 AT localhost> <SERRANOAGPBnSZh3DHR0000006d AT SERRANO DOT CAM DOT ARTIMI DOT COM>
Mime-Version: 1.0
In-Reply-To: <SERRANOAGPBnSZh3DHR0000006d@SERRANO.CAM.ARTIMI.COM>
User-Agent: Mutt/1.5.6i

On Wed, Mar 16, 2005 at 06:06:20PM -0000, Dave Korn wrote:
>----Original Message----
>>From: Andrew Schulman
>>Sent: 16 March 2005 17:08
>
>
>> Would the job be easier in my case, where I have a repeatable crash?  I
>> provided strace output in the earlier thread about my autossh problems,
>> but haven't tried using any debug builds of cygwin1.dll.  I'm not
>> conversant with debuggers, but I have used gdb before and could work my
>> way through it.  Let me know if this would be useful, and how best to go
>> about it.
>
>
>  Thanks, it's good of you to offer, but as you may have seen, cgf's already
>put his finger on it: the code in autossh calls free (...) on a pointer that
>it didn't get from one of the *alloc (...)-family functions.  That's the
>problem (undefined behaviour) and his fix is the correct solution.

No, it is freeing something that *was* allocated using malloc by cygwin
but cygwin expects that it should be able to control the allocation
since the caller shouldn't be making any assumptions about where the
buffer lives.  The buffer could be on the heap or it could be statically
allocated.

>  GOK why it works on glibc-based systems, but I guess it must, or the
>problem would surely have cropped up before.  Hmmmmm......
>
>dk AT mace /gnu/glibc-2.3.4/resolv> cat -n gethnamaddr.c
> [........snip!........]
>   103
>   104  static struct hostent host;
>   105  static char *host_aliases[MAXALIASES];
>   106  static char hostbuf[8*1024];
> [........snip!........]
>
>  Well, it also uses a static buffer.  Guess glibc free (...) must be more
>robust in the presence of garbage input than newlib free (...), although
>that's odd, since they're both based on dl-malloc under the hood.

Cygwin doesn't use newlib's free.

cgf

--
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