On Fri, Apr 25, 2014 at 11:37 AM, Philip Martin
<philip.mar...@wandisco.com>wrote:

> Experimenting with gcc 4.9's -fsantize=undefined I got a warning:
>
> $ svnadmin create repo
> $ svn mkdir -mm file://`pwd`/repo/A
> ../src/subversion/libsvn_fs_fs/transaction.c:1978:14: runtime error: shift
> exponent -1 is negative
>
> The code is
>
>    1976       /* We also don't want the linear deltification to span more
> shards
>    1977          than deltas would be used in the simple skip-delta schme.
> */
>    1978       if ((1 << (--shards)) <= walk)
>    1979         count = noderev->predecessor_count - 1;
>

The bug is that shards can be 0 to begin with.
Any non-zero walk needs to start somewhere ...
(and walk cannot be 0 here).


> Perhaps something like this:
>
> Index: subversion/libsvn_fs_fs/transaction.c
> ===================================================================
> --- subversion/libsvn_fs_fs/transaction.c       (revision 1589957)
> +++ subversion/libsvn_fs_fs/transaction.c       (working copy)
> @@ -1975,7 +1975,7 @@ choose_delta_base(representation_t **rep,
>
>        /* We also don't want the linear deltification to span more shards
>           than deltas would be used in the simple skip-delta schme. */
> -      if ((1 << (--shards)) <= walk)
> +      if (shards > 0 && (1 << (--shards)) <= walk)
>          count = noderev->predecessor_count - 1;
>      }
>

I decided to fix the problem in the shards_spanned()
function - see r1590383.

Thanks for experimenting!

-- Stefan^2.

Reply via email to