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

BDB segv with NULL checksum

From: Philip Martin <philip.martin_at_wandisco.com>
Date: Wed, 03 Apr 2013 22:04:00 +0100

As part of http://subversion.tigris.org/issues/show_bug.cgi?id=4344 I
was playing with a BDB repository created by driving the svn_fs API
directly in repos-test.c:node_locations2. This creates a revision where
a file has no checksum. A subsequent commit that modifies the file can
SEGV:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ff8d49ab700 (LWP 4957)]
0x00007ff8d6430320 in txn_body_apply_textdelta (baton=0x7ff8da368dc0,
    trail=0x7ff8da368e60) at ../src/subversion/libsvn_fs_base/tree.c:3733
3733 if (tb->base_checksum->kind == checksum->kind

because svn_fs_base__dag_file_checksum returns a NULL checksum as the
documentation allows (repos-test itself doesn't SEGV because it
doesn't pass a base checksum, but if you interrupt the test after r2 and
then checkout/commit using a standard client the SEGV occurs).

I can fix the SEGV using this patch:

Index: ../src/subversion/libsvn_fs_base/tree.c
===================================================================
--- ../src/subversion/libsvn_fs_base/tree.c (revision 1464080)
+++ ../src/subversion/libsvn_fs_base/tree.c (working copy)
@@ -3730,7 +3730,7 @@
          we're calculating both SHA1 and MD5 checksums somewhere in
          reps-strings.c. Could we keep them both around somehow so this
          check could be more comprehensive? */
- if (tb->base_checksum->kind == checksum->kind
+ if (checksum && tb->base_checksum->kind == checksum->kind
             && !svn_checksum_match(tb->base_checksum, checksum))
         return svn_checksum_mismatch_err(tb->base_checksum, checksum,
                             trail->pool,

If I look at the FSFS code it doesn't do the kind comparison, it was
removed in r874326 but that's a revert which may have reverted more than
intended. The FSFS code does:

      if (!svn_checksum_match(tb->base_checksum, checksum))
        return svn_checksum_mismatch_err(tb->base_checksum, checksum, pool,
                                         _("Base checksum mismatch on '%s'"),
                                         tb->path);

so I can also fix the SEGV with:

Index: ../src/subversion/libsvn_fs_base/tree.c
===================================================================
--- ../src/subversion/libsvn_fs_base/tree.c (revision 1464080)
+++ ../src/subversion/libsvn_fs_base/tree.c (working copy)
@@ -3730,8 +3730,7 @@
          we're calculating both SHA1 and MD5 checksums somewhere in
          reps-strings.c. Could we keep them both around somehow so this
          check could be more comprehensive? */
- if (tb->base_checksum->kind == checksum->kind
- && !svn_checksum_match(tb->base_checksum, checksum))
+ if (!svn_checksum_match(tb->base_checksum, checksum))
         return svn_checksum_mismatch_err(tb->base_checksum, checksum,
                             trail->pool,
                             _("Base checksum mismatch on '%s'"),

Which patch should I apply? Should BDB and FSFS be the same?

-- 
Certified & Supported Apache Subversion Downloads:
http://www.wandisco.com/subversion/download
Received on 2013-04-03 23:04:45 CEST

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