This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


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

BUG: RCS truncates files (possible stdio bug)


Anybody managed to build a working RCS?  I have been trying to build it
for a while, but ran into a rather ugly bug described below. I have seen
the truncation problem mentioned before (about a month ago) on this
list, but the previuos poster was not able to reproduce the problem.

Environment: Windows NT 4.0 SP3 
	     "uname -a" => CYGWIN32_NT KARLSEN 4.0 19.1 i586 unknown
(Also experienced with b18.)
All mounts binary.

Package: RCS 5.7 sources from ftp.gnu.ai.mit.edu.
Summary: ci truncates latest rev. to 1024 bytes when inserting text
	 into the first 1024 bytes of the working file.
Build:	 Configure and compilation runs (seemingly) without errors after
	 applying the 2 changes mentioned in M. Hirmke's package report,
	 Message-ID: <6qrVmni$pfB@mike.franken.de>.

Reproduction: 
Input files: rcsbug.txt.org. Optionally, use the enclosed
shell-script prepare-ci-bug.sh which I made to automate exposure of this
bug.  To use it, first edit the RCS_BIN variable to the location of your
RCS executables.  

$ export RCSINIT=-x 

(Eliminates the use of ",v" suffixes on RCS files, I can't have path
names with ',' in them because of Win95 compatibility.)  (I even tried
without it, got a messed up file name, ",rcsbug.txt," in the current
directory and the first co failed.  Could this be related to the
readlink() bug previously mentioned in the mailing list, and supposedly
fixed with latest cygwinb19.dll?)  
Put rcsbug.txt.org in a directory. Make an "RCS" subdirectory: 

$ mkdir RCS 
$ cp rcsbug.txt.org rcsbug.txt

Put location of cygwin32-compiled RCS execuatbles first in your path,
or spell the path out explicitly, e.g. /h/src/rcs-5.7/src/ci.exe.  

$ ci -u rcsbug.txt 
$ co -l rcsbug.txt 

Edit the working file by adding some text before the 1024th
position. See the enclosed shell script for an example.  The edits done
by the script consist of adding 5 lines at about pos. 800, that is, the end of
the line consisting of 'm'-s.  The size of the inserted text doesn't
seem to matter, I have tried sizes from around 100 to >1200 bytes with
similar results. The byte position doesn't seem to matter, as long as
it's less than 1024. 

$ ci -u rcsbug.txt

The latest rev. in the RCS file RCS/rcsbug.txt is now truncated to
exactly 1024 bytes, which can be easily seen by checking the file out
again: 

$ co -l rcsbug.txt

Fine print: I have debugged (using gdb) this down to the 'putdftext'
routine in the file src/rcsgen.c. The getc/putc (the macros from
rcs/rcsbase.h basicly expands to this + error checks) loop at lines
660-664 terminates prematurely because getc() returns EOF after exactly
1024 iterations (the __SFEOF bit is set in the '_flags' member of the
'__SFILE' struct corresponding to the input file). This indicates that
there might be a bug in cygwin32's putc() implementation.

Ideally, I would like to reproduce all file IO done by RCS in a
separate test program to isolate the bug further, but this seems too
tedious and time-comsuming at the moment. I would appreciate if someone
could test/confirm this and maybe track the bug down to either cywin32 or
RCS.

Thanks for great software and mailing list.

Sven-Jørgen 

rcsbug.txt.org:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
ggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq
rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss

prepare-ci-bug.sh:
#! /bin/sh
RCS_BIN=/h/src/rcs-5.7/src	# Location of RCS executables.
# Line where sed insert $INSERT_STRING
INSERT_LINE=16
# The sed replacement string. Note that "\\" is sed's newline.
INSERT_STRING="\\
Here we insert some text at pos. < 1024 bytes to show \\
the truncation bug. After this editing, a \"ci -u\" on this file\\
will result in the file being truncated to exactly 1024 bytes.\\
"

TESTFILE_ORG=rcsbug.txt.org
TESTFILE=rcsbug.txt
CI_OPTIONS="-u -t-Test"   # -u: Leave working file,
			  # -t-: Desc. for the new RCS file (automates prompt).

CO_OPTIONS=-l			# -l: Check out locked.

# Cleanup from previous runs.
if [ -e "RCS" ]; then rm -f RCS/*; fi

cp -f $TESTFILE_ORG $TESTFILE
$RCS_BIN/ci.exe $CI_OPTIONS $TESTFILE
$RCS_BIN/co.exe -l $TESTFILE

sed "${INSERT_LINE}i\\
$INSERT_STRING" $TESTFILE_ORG > $TESTFILE

-- 
Two is not equal to three, even for large values of two.

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