bug-rcs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bug #41707: RCS 5.8 file corruption when using file descriptor IO fo


From: Achim Gratz
Subject: Re: bug #41707: RCS 5.8 file corruption when using file descriptor IO for large files
Date: Sun, 07 Sep 2014 10:22:45 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.93 (gnu/linux)

Thien-Thi Nguyen writes:
> BTW, i've just deleted branch ‘q-spurious-eof’ and added
> branch ‘q-desync’ instead.  Everything is squashed down,
> including src/z.c, now revised to do the post-‘lseek’.

The post-lseek fix is apparently working in z, although to be sure you'd
have to check that not only you got the right number of bytes, but also
the correct data (i.e. using /dev/random as source and checking the
reads against a memory copy of the file).  The results for y and z runs
inline in the files.  In ci the attempted fixup still doesn't work, so I
offer my patch again which tests OK and should be good for any other
system as well.  I've also fixed Makefile.am to actually include the new
test in "make check".

>From 22da9e9a5717c4ff1f4397d86631b1b206e24777 Mon Sep 17 00:00:00 2001
From: Achim Gratz <address@hidden>
Date: Sun, 7 Sep 2014 10:17:49 +0200
Subject: [PATCH] fix up branch q-desync

---
 src/ci.c          | 11 ++++++-----
 src/y.c           | 11 +++++++++--
 src/z.c           | 34 ++++++++++++++++++++++++++++++++--
 tests/Makefile.am |  1 +
 4 files changed, 48 insertions(+), 9 deletions(-)

diff --git a/src/ci.c b/src/ci.c
index 6f7e291..047d9f5 100644
--- a/src/ci.c
+++ b/src/ci.c
@@ -1076,8 +1076,8 @@ ci_main (const char *cmd, int argc, char **argv)
                 SAME_AFTER (from, bud.target->text);
                 bud.d.pretty_log = getlogmsg (&reason, &bud);
 
-                /* "Rewind" ‘work.fro’ before feeding it to diff(1).  */
-                fro_bob (work.fro);
+               /* Position the fd at the beginning of the file before
+                  the exec of diff(1). */
                 if (PROB (lseek (wfd, 0, SEEK_SET)))
                   Ierror ();
 
@@ -1093,9 +1093,10 @@ ci_main (const char *cmd, int argc, char **argv)
                 if (DIFF_TROUBLE == runv (wfd, diffname, diffv))
                   RFATAL ("diff failed");
 
-                if (STDIO_P (work.fro)
-                    && PROB (lseek (wfd, 0, SEEK_SET)))
-                  Ierror ();
+                /* "Rewind" ‘work.fro’ only after feeding it to
+                  diff(1).  This is needed to keep the stream
+                  buffer state in sync with the fd. */
+                fro_bob (work.fro);
 
                 if (newhead)
                   {
diff --git a/src/y.c b/src/y.c
index aca680e..a1dd040 100644
--- a/src/y.c
+++ b/src/y.c
@@ -40,8 +40,15 @@
 // |     0      0 -- fflush
 // |     0      0 -- lseek
 //
-// * "cygwin" -- ?
-// ???
+// * x86_64-pc-cygwin -- 0
+// |     0      0 -- init
+// |     0  65536 -- 64KiB
+// |     1  65537 -- +1
+// |     1  65537 -- failed +1 (EOF)
+// |     1  65537 -- feof sanity check
+// |     0      0 -- fseek 0
+// |     0      0 -- fflush
+// |     0      0 -- lseek
 
 #include <sys/types.h>
 #include <unistd.h>
diff --git a/src/z.c b/src/z.c
index dfe20fe..95df551 100644
--- a/src/z.c
+++ b/src/z.c
@@ -85,8 +85,38 @@
    |pgot[16]: 8192 => 131072
    |pgot[17]: 0 => 131072
 
-   * "cygwin" -- ?
-   |???
+   * x86_64-pc-cygwin -- 0
+   |args: [0]./z
+   |fd: 3
+   |size: 131072
+   |pgot[1]: 8192 => 8192
+   |pgot[2]: 8192 => 16384
+   |pgot[3]: 8192 => 24576
+   |pgot[4]: 8192 => 32768
+   |pgot[5]: 8192 => 40960
+   |at: fd=65536 st=40960
+   |at: fd=0 st=0
+   |args: [0]./z [1]child
+   |at: fd=131072 st=0
+   |chk_bob failed!
+   |=> fixing fd!
+   |pgot[1]: 8192 => 8192
+   |pgot[2]: 8192 => 16384
+   |pgot[3]: 8192 => 24576
+   |pgot[4]: 8192 => 32768
+   |pgot[5]: 8192 => 40960
+   |pgot[6]: 8192 => 49152
+   |pgot[7]: 8192 => 57344
+   |pgot[8]: 8192 => 65536
+   |pgot[9]: 8192 => 73728
+   |pgot[10]: 8192 => 81920
+   |pgot[11]: 8192 => 90112
+   |pgot[12]: 8192 => 98304
+   |pgot[13]: 8192 => 106496
+   |pgot[14]: 8192 => 114688
+   |pgot[15]: 8192 => 122880
+   |pgot[16]: 8192 => 131072
+   |pgot[17]: 0 => 131072
 
 */
 
diff --git a/tests/Makefile.am b/tests/Makefile.am
index bec6076..a2d2606 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -80,6 +80,7 @@ TESTS = \
  t803 \
  t804 \
  t810 \
+ t820 \
  t900 \
  t999
 
-- 
2.0.4

> There is also new program src/y.c to play with.  I'm curious
> how these behave under Cygwin.

Exactly as under Linux, it appears.

> Also, the original (2010)
> configure-time test is back, in case you want to try to see
> if/how ‘CAN_FFLUSH_IN’ is detected under Cygwin.

Results in a "yes".


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

SD adaptations for Waldorf Q V3.00R3 and Q+ V3.54R2:
http://Synth.Stromeko.net/Downloads.html#WaldorfSDada

reply via email to

[Prev in Thread] Current Thread [Next in Thread]