[BUG] bug in weave.join() code

John Arbash Meinel john at arbash-meinel.com
Tue Jan 24 22:30:32 GMT 2006


Goffredo Baroncelli wrote:
> On Tuesday 24 January 2006 21:21, John Arbash Meinel wrote:
> 
>>I found a pretty large bug in the Weave.join() code, which causes the
>>code to freak out quite a bit. Specifically the code:
>>
>>if name in self._names:
>>    idx = self.lookup(name)
>>    n1 = map(other.idx_to_name, other._parents[other_idx] )
>>    n2 = map(self.idx_to_name, self._parents[other_idx] )
>>    if sha1 ==  self._sha1s[idx] and n1 == n2:
>>        continue
>>
>>Notice that it uses other_idx instead of 'idx' so this should be:
>>    n2 = map(self.idx_to_name, self._parents[idx] )
> 
> 
> I wrote the code, so I can confirm that this is a bug! 
> However it very difficult that this bug can compromise the wevae,
> in fact in order to raise the bug it have to happend:
> 
>   weave1._parents[weave2_idx] == weave2._parents[weave2_idx] 
> and
>   sort(weave1._parents[weave1_idx]) != sort(weave2._parents[weave2_idx])
> 
> this can happen, but it is not very frequent
> 
> :-)
> 
> The patch below should solve,please Martin apply
> 
> === modified file 'bzrlib/weave.py'
> --- bzrlib/weave.py
> +++ bzrlib/weave.py
> @@ -833,7 +833,9 @@
>              if name in self._names:
>                  idx = self.lookup(name)
>                  n1 = map(other.idx_to_name, other._parents[other_idx] )
> -                n2 = map(self.idx_to_name, self._parents[other_idx] )
> +                n2 = map(self.idx_to_name, self._parents[idx] )
> +                n1.sort( )
> +                n2.sort( )
>                  if sha1 ==  self._sha1s[idx] and n1 == n2:
>                          continue

yeah. I'm actually thinking to use sets, but the above would do the trick.

I'm looking into writing a test case, which is a little bit tricky,
because you have to instrument the Weave class, so that you can figure
out what code path is being taken.

What is happening is that the reweave() code path is causing parents to
get re-ordered. So it is happening more often now than it used to.

It wouldn't cause corruption, but it changed 'bzr merge' from being 11s
to being 10min for me.

John
=:->
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 256 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060124/5805b6ba/attachment.pgp 


More information about the bazaar mailing list