[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
MSVC compiler support [patch 28]: setvbuf crash
From: |
John W. Eaton |
Subject: |
MSVC compiler support [patch 28]: setvbuf crash |
Date: |
Wed, 25 Oct 2006 21:18:22 -0400 |
On 17-Oct-2006, Michael Goffioul wrote:
| setvbuf leads to a crash when called on a pipe (don't know why).
|
| Index: src/oct-procbuf.cc
| ===================================================================
| RCS file: /cvs/octave/src/oct-procbuf.cc,v
| retrieving revision 1.30
| diff -p -c -r1.30 oct-procbuf.cc
| *** src/oct-procbuf.cc 8 May 2006 20:23:05 -0000 1.30
| --- src/oct-procbuf.cc 17 Oct 2006 11:07:42 -0000
| *************** octave_procbuf::open (const char *comman
| *** 78,85 ****
| --- 78,87 ----
|
| open_p = true;
|
| + #ifndef _MSC_VER
| if (mode & std::ios::out)
| ::setvbuf (f, 0, _IOLBF, 0);
| + #endif
|
| return this;
Perhaps this is crashing because size (the final argument) is 0. Can
you try using something like 1024 and see if that works? My
understanding was that if the buffer pointer was 0, the buffer would
be automatically allocated, and at some point I must have thought that
the buffer would also be appropriately sized if the SIZE argument is
0. But the MSDN man page says
The array pointed to by buffer is used as the buffer, unless it is
NULL, in which case setvbuf uses an automatically allocated buffer
of length size/2 * 2 bytes.
so I guess we need to set size to a nonzero value. I think POSIX
specifies BUFSIZE as an approprite size, so I changed this code to use
:setvbuf (f, 0, _IOLBF, BUFSIZ);
and I'm defining BUFSIZ at the top of the file this way:
#ifndef BUFSIZ
#define BUFSIZ 1024
#endif
Thanks,
jwe
- MSVC compiler support [patch 24]: strftime crash, (continued)
- MSVC compiler support [patch 26]: MinGW code share, Michael Goffioul, 2006/10/17
- MSVC compiler support [patch 26]: MinGW code share, John W. Eaton, 2006/10/25
- MSVC compiler support [patch 27]: OCTAVE_HOME, Michael Goffioul, 2006/10/17
- Re: MSVC compiler support [patch 27]: OCTAVE_HOME, David Bateman, 2006/10/17
- Re: MSVC compiler support [patch 27]: OCTAVE_HOME, Michael Goffioul, 2006/10/17
- Re: MSVC compiler support [patch 27]: OCTAVE_HOME, Michael Goffioul, 2006/10/18
- Re: MSVC compiler support [patch 27]: OCTAVE_HOME, John W. Eaton, 2006/10/24
- MSVC compiler support [patch 28]: setvbuf crash, Michael Goffioul, 2006/10/17
- MSVC compiler support [patch 28]: setvbuf crash,
John W. Eaton <=
- MSVC compiler support [patch 29]: Backslash in path, Michael Goffioul, 2006/10/17
- MSVC compiler support [patch 29]: Backslash in path, John W. Eaton, 2006/10/27
- MSVC compiler support [patch 30]: Help MSVC with templates, Michael Goffioul, 2006/10/17
- MSVC compiler support [patch 30]: Help MSVC with templates, John W. Eaton, 2006/10/26
- MSVC compiler support [patch 31]: CHAR_BIT, Michael Goffioul, 2006/10/17
- MSVC compiler support [patch 31]: CHAR_BIT, John W. Eaton, 2006/10/17
- MSVC compiler support [patch 32]: ls, Michael Goffioul, 2006/10/17
- MSVC compiler support [patch 32]: ls, John W. Eaton, 2006/10/27
- Re: MSVC compiler support [patch 32]: ls, Michael Goffioul, 2006/10/27
- Re: MSVC compiler support [patch 32]: ls, John W. Eaton, 2006/10/27