[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH]: SIGSEGV in repos to repos copy

From: David Kimdon <dwhedon_at_debian.org>
Date: 2002-11-22 07:18:27 CET

Hi,

Here's a recipie for a segfault, plus a fix. The fix looks right, but I'd like
a second opinion.

$ cat crash
#!/bin/sh

REPOS=$HOME/tmp/repos
WC=$HOME/tmp/wc

rm -rf $REPOS
rm -rf $WC
mkdir -p $REPOS
mkdir -p $WC

svnadmin create $REPOS

mkdir $WC/proj
touch $WC/proj/file

svn mkdir -q -m '' file:///$REPOS/A
svn mkdir -q -m '' file:///$REPOS/A/B
svn import -q -m '' file:///$REPOS/A/B $WC/proj C
svn move -q -m '' file:///$REPOS/A/B/C file:///$REPOS/A

svn mkdir -q -m '' file:///$REPOS/D
svn import -q -m '' file:///$REPOS/D $WC/proj E
svn move -q -m '' file:///$REPOS/D/E file:///$REPOS/D
$ ./crash
./crash: line 19: 28437 Segmentation fault svn move -q -m '' file:///$REPOS/A/B/C file:///$REPOS/A
./crash: line 23: 28440 Segmentation fault svn move -q -m '' file:///$REPOS/D/E file:///$REPOS/D
$

gdb to the rescue.

After applying the included patch the first move succeeds as it should while
the second exits gracefully with an informative error message.

$ ./crash
subversion/libsvn_client/copy.c:306: (apr_err=160020, src_err=0)
svn: Item already exists in filesystem
svn: fs path `D/E' already exists.
$

-David

* subversion/libsvn_client/copy.c: (repos_to_repos_copy) When doing a repos to
  repos copy if source is a subdir of destination we need to open an RA session
  of the parent of source, otherwise we segfault when trying to determine the
  repos destination path.

Index: subversion/libsvn_client/copy.c
===================================================================
--- subversion/libsvn_client/copy.c (revision 3850)
+++ subversion/libsvn_client/copy.c (working copy)
@@ -208,11 +208,14 @@
      case of a move. */
   top_url = svn_path_get_longest_ancestor (src_url, dst_url, pool);
 
- /* Special edge-case! (issue #683) If you're resurrecting a
+ /* Special edge-case! (issue #683 et al.) If you're resurrecting a
      deleted item like this: 'svn cp -rN src_URL dst_URL', then it's
      possible for src_URL == dst_URL == top_url. In this situation,
- we want to open an RA session to the *parent* of all three. */
- if (! strcmp (src_url, dst_url))
+ we want to open an RA session to the *parent* of all three.
+ Likewise if src_URL is a subdir of dst_URL we need to open the
+ parent. */
+ if (! strcmp (src_url, dst_url) ||
+ svn_path_is_child(dst_url, src_url, pool) )
     top_url = svn_path_dirname (top_url, pool);
 
   /* Get the portions of the SRC and DST URLs that are relative to

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Nov 22 07:18:41 2002

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.