BUG IN CVS-1.10 AND HOW TO FIX IT !!!!

BUG IN CVS-1.10 AND HOW TO FIX IT !!!!

Post by Leo Razoumo » Fri, 18 Sep 1998 04:00:00



I found a CVS-1.10 specific bug which causes cvs Segmentation Fault and core
dump on fatal "diff" errors. I observed this bug on SUN Solaris-2.5 with
gcc-2.7.2.1 but the nature of the bug is cross-platform and does not depend
on compiler used.

SIDE EFFECTS:
   1) File locks are left behind in the repository and they have to be
      deleted manually.
   2) CVS repository might be left in inconsistent state.
   3) generated core file clutters your working directory.
   4) bad language of a programmer losing confidence in CVS software:-)

BUG DISCRIPTION:
    Assuming that you have a file "foo.c" under CVS control in your working
    directory, issue the following command:

    $ cvs diff -C foo.c

    CVS-1.10 dumps core. You might notice that option '-C' requires a number
    as its argument. Omitting the number should result in an error message
    but *not* in a Segmentation Fault and a core dump!

CAUSE OF THE BUG:
    Function diff_run(...) defined in cvs-1.10/diff/diff.c processes
    command line arguments for "diff" and in case of illegal usage it
    calls fatal() which in turn calls longjmp(...).
    Unfortunately, in cvs-1.10 the target point for longjmp(...) is set by
    setjmp(...) *after* the calls to fatal(...).
    Therefore longjmp(...) uses uninitialized target-point which naturally
    results in Segmentation violation.

BUG FIX:
    A patch file (produced with diff -c) which solves the
    problem is attached to the end of this message.

hope it helps,
-- Leo

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

+  Qualcomm Inc.,                 +  http://www.qualcomm.com          +
+  6455 Lusk Blvd.,               +                                   +
+  San Diego, CA 92121-2779,      +  VOICE:  +1-619/65-15163          +
+        USA                      +                                   +
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

############################################################################
# This is a patch file to be applied to cvs-1.10/diff/diff.c  to fix
# a bug which causes cvs-1.10 to core dump on fatal "diff" errors.
#
# Applying the patch: First save this file as "cvs-1.10/diff/diff.c_PH".
# Next:
# $ cd cvs-1.10/diff
# $ patch -b diff.c diff.c_PH
#
# Your original version of "diff.c" is saved as "diff.c.orig"
# while "diff.c" contains all necessary changes.
#
# Enjoy, Leo
############################################################################

*** diff.c_ORI  Thu Sep 17 15:59:28 1998
--- diff.c      Thu Sep 17 16:17:30 1998
***************
*** 254,259 ****
--- 254,270 ----

    optind_old = optind;
    optind = 0;
+
+   /* Set the jump buffer, so that diff may abort execution without
+      terminating the process. */
+   if ((val = setjmp (diff_abort_buf)) != 0)
+     {
+       optind = optind_old;
+       if (opened_file)
+       fclose (outfile);
+       return val;
+     }
+
    while ((c = getopt_long (argc, argv,
                           "0123456789abBcC:dD:efF:hHiI:lL:nNpPqrsS:tTuU:vwW:x:X:y",
                           longopts, 0)) != EOF)
***************
*** 686,701 ****
            }
          opened_file = 1;
        }
-     }
-
-   /* Set the jump buffer, so that diff may abort execution without
-      terminating the process. */
-   if ((val = setjmp (diff_abort_buf)) != 0)
-     {
-       optind = optind_old;
-       if (opened_file)
-       fclose (outfile);
-       return val;
      }

    val = compare_files (0, argv[optind], 0, argv[optind + 1], 0);
--- 697,702 ----

 
 
 

1. cvs server : cvs co -d ... not working (1.10.5 and 1.10.6)

With the ext method, using rsh, here's what happening :
With a local repository,
cvs co -d . dir
checks out the dir hierarchy in the current repository.

With the same repository accessed by remote shell
cvs co -d . dir
gives
cvs server: existing repository /repository does not match
/repository/dir
cvs server: ignoring module dir

Also, if I specify an absolute path to the -d option, it is ok with
local
repository and gives
cvs [server aborted]: absolute pathname `/users/fimatex/roth/tmp'
illegal
for server
with a remote repository.

The cvs version on the server is 1.10.6, is this bug known and fixed in
1.10.7 ? I also wonder if the client version matters while using rsh :
is it
the client that operates remotely on the repository, or the server that
executes remote orders from the client??

TIA

Michel-Ange CAMHI
Ingnieur systme - ATOS Multimdia
ATOS - ZI La Pointe - 59113 Seclin
Tel: 33+ (0)3 20 60 7896 - Fax: 33+ (0)3 20 60 7649 -

2. Multiple resultset Datatable structure

3. BUG: cvs 1.10.2, read-only files, and Windows NT

4. Which tool of Cadence does (block) placement (floorplanning)?

5. CVS Windows NT Bug & Fix: wrong timestamps with "cvs -r checkout"

6. About "who am i" and "whoami"

7. CVS 1.10.5 and 1.10.6

8. Outlook 5 Error message 0X800CCC0E

9. patch for test cvs-1.10 needed

10. CVS-1.10 pserver on AIX-4.2.1 - port 2401 already in use

11. cvs-1.10 -- repository corruption on import?

12. can't build CVS-1.10 on Solaris 7 x86

13. CVS: What does 'P' mean on update - CVS 1.10.3 WinNT Client