Bzr status fails with infinite loop for repo at filesystem root (aka /)

Bug #861008 reported by Florian Vichot
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
Medium
Florian Vichot
2.4
Fix Released
Medium
Florian Vichot

Bug Description

I use a Bzr repo in / to version /etc, /opt and other important system files.

It worked fine for "bzr add" and "bzr commit", but went into infinite loop for "bzr status".

I added some debug "print", and finally identified the problem to be coming from the relpath() method in the posixpath module. Indeed, sometime paths such as '//etc/shadow' would be passed to the function, and this would block the main loop into a infinite loop, as it would try to make '/' (the basepath) and '//' correspond. For some reason, the "split()" call at the end would return ('//', '') for a call with '//' as the argument. Apparently it's intentional, according to the comment above the function definition in posixpath.py, around line 80 : "# Trailing '/'es are stripped from head unless it is the root.". I fail to see why this is necessary.

FYI, I tried to fix it using "rp = normpath(rp)" before the "while True" loop in relpath(), hoping it would simplify the '//' into '/', but again, it's documented in the comments above the definition of normpath() in posixpath.py that if the path contains exactly two leading slashes, POSIX stipulates they must be left alone, and only if there is 3 or more should they be simplified as one (!!). Apparently this is to accomodate DomainOS, an old OS that doesn't even exist anymore...

Anyway, I patched it quite unelegantly with :

    if rp.startswith('//') :
        rp = rp[1:]

in relpath(), just before the "while True:" loop. And it works fine :)

This is in bzr 2.4.1

Related branches

description: updated
description: updated
Revision history for this message
Martin Pool (mbp) wrote :

Thanks for identifying this. Could you put up your fix in a branch and propose merging it into lp:bzr? See http://wiki.bazaar.canonical.com/BzrGivingBack

Changed in bzr:
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Florian Vichot (florian-vichot) wrote :
Martin Packman (gz)
Changed in bzr:
assignee: nobody → Florian Vichot (florian-vichot)
milestone: none → 2.5b2
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.