This is the mail archive of the libc-alpha@sourceware.cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[Various] libc/1616: core dump after changing buffer using setvbuf



Hi glibc folks,

we've received the appended bug report together with a patch that
should fix the problem.

Could somebody please check whether the fix is correct?  Ulrich told
me privatly that he thinks the problem should be elsewhere.

Thanks,
Andreas



Topics:
   libc/1616: core dump after changing buffer using setvbuf
   Re: libc/1616: core dump after changing buffer using setvbuf


----------------------------------------------------------------------

Date: Tue, 29 Feb 2000 13:15:27 -0500
From: r.de.vries@fokkerspace.nl
To: bugs@gnu.org
Subject: libc/1616: core dump after changing buffer using setvbuf
Message-Id: <200002291815.NAA05044@delysid.gnu.org>


>Number:         1616
>Category:       libc
>Synopsis:       core dump after changing buffer using setvbuf
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    libc-gnats
>State:          open
>Class:          sw-bug
>Submitter-Id:   unknown
>Arrival-Date:   Tue Feb 29 13:20:01 EST 2000
>Last-Modified:
>Originator:     r.de.vries@fokkerspace.nl
>Organization:
net
>Release:        2.1.2
>Environment:
Linux Redhat 6.1
Pentium processor
>Description:
After changing the buffer of a file using setvbuf a segmentation fault occurs
when writing to the file.
>How-To-Repeat:
Compile and run....
It is essential to write something before calling setvbuf().
If you let the C library provide its own buffer, everything works as well.


#include <stdio.h>

#define MYBUFSIZE 10240

int main(void)
{
  FILE *f;
  char buf[MYBUFSIZE];

  f = fopen("foo", "w");
  putc('\n', f);
  fflush(f);

  setvbuf(f, buf, _IOFBF, MYBUFSIZE);

  for ( ; ; ) fwrite("die", 3, 1, f);
}%0
>Fix:
>Audit-Trail:
>Unformatted:


------------------------------

Date: Tue, 29 Feb 2000 17:30:02 -0500
From: Robert de Vries <rhdv@rhdv.cistron.nl>
To: libc-gnats@gnu.org
Cc: gnats-admin@gnu.org
Subject: Re: libc/1616: core dump after changing buffer using setvbuf
Message-Id: <200002292230.RAA27709@mescaline.gnu.org>

The following reply was made to PR libc/1616; it has been noted by GNATS.

From: Robert de Vries <rhdv@rhdv.cistron.nl>
To: bugs@gnu.org
Cc: r.de.vries@fokkerspace.nl
Subject: Re: libc/1616: core dump after changing buffer using setvbuf
Date: Tue, 29 Feb 2000 23:28:00 +0100 (CET)

 I have verified that the patch below fixes the problem.
 
 --- libio/fileops.c~	Wed Aug 25 08:49:15 1999
 +++ libio/fileops.c	Tue Feb 29 22:46:50 2000
 @@ -280,8 +280,9 @@
      if (_IO_default_setbuf (fp, p, len) == NULL)
        return NULL;
  
 -    fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_write_end
 -      = fp->_IO_buf_base;
 +    fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_buf_base;
 +    fp->_IO_write_end = fp->_IO_buf_end;
 +
      _IO_setg (fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base);
  
      return fp;
 
 
 -- 
 Robert de Vries
 rhdv@rhdv.cistron.nl
 


------------------------------

End of forwardmvEMp0 Digest
***************************



-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de
   private aj@arthur.rhein-neckar.de

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]