delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1999/01/16/20:45:31

From: cgf AT cygnus DOT com (Christopher G. Faylor)
Subject: Re: B20.1: setvbuf implementation incorrect for <mode> == _IONBF
16 Jan 1999 20:45:31 GMT :
Message-ID: <77qtpb$2kt$1@cronkite.cygnus.com>
References: <36A02ABA DOT AC1E4249 DOT cygnus DOT gnu-win32 AT CMPU DOT NET>
X-Newsreader: trn 4.0-test63 (15 March 1998)

In article <36A02ABA DOT AC1E4249 DOT cygnus DOT gnu-win32 AT CMPU DOT NET>,
Tom Shields <Shields AT cmpu DOT net> wrote:
>The implementation of setvbuf in the B20.1 source release is
>incorrect if the mode parameter is _IONBF (unbuffered IO); it
>doesn't deallocate the current buffer (there will be one), which
>is a cause of memory leaks, but more importantly it overwrites
>the buffer heap pointer but leaves the __SMBF flag set indicating
>that there is a heap allocated buffer, so that when fclose is
>invoked, it eventually tries to free a non-heap pointer value,
>which causes the run-time exception STATUS_ACCESS_VIOLATION.
>
>I've appended a simple fix - the invocation of fflush is unnecessary
>for this case, since setvbuf is supposed to be called prior to
>doing any IO on the file, but this fix is the least perturbation
>to the source.

I've installed a similar fix to our sources.  Thanks for catching
this.

>I rebuilt b20.1, and put cygwin1.dll in my test app's directory
>(PATH includes ".") for verification, but I'm experiencing wierd
>behavior now: my test app craters immediately with another
>STATUS_ACCESS_VIOLATION if I run it from the bash command line
>(as opposed to cratering at the end of execution with the fclose),
>but if I run the test app under gdb it works perfectly now (no
>STATUS_ACCESS_VIOLATION in the fclose)!
>
>Can someone explain what is going on? I'm hesitant to install
>the rebuilt b20.1 environment due to this strange behavior.

It's difficult to explain without knowing exactly where your test app is
"cratering".  Is this a problem for all of your applications or is it
only the ones which use _IONBF?
-- 
cgf AT cygnus DOT com
http://www.cygnus.com/

- Raw text -


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