"Permission denied" errors removing test directories on Windows.

Mark Hammond mhammond at skippinet.com.au
Sat Jun 28 08:32:23 BST 2008


FYI, here is an example of one which is solved by the gc.collect() addition:

% bzr selftest blackbox.test_push.TestPush.test_push_only_pushes_history
| FAIL: blackbox.test_push.TestPush.test_push_only_pushes_history
|     Unexpected return code
| not equal:
| a = 0
| b = 3
| Permission denied: unable to remove testing dir tmp9vrlfb

at which point I broke into the debugger.  Via the debugger I did gc.collect().  bzr then output:

"""
o:\src\bazaar\bzr.dev\bzrlib\lockable_files.py:111: UserWarning: LockableFiles(<bzrlib.transport.local.LocalTransport url=file:///O:/window%7E1/testbzr-yoiuv8.tmp/tmp9vrlfb/work/push-b/.bzr/checkout/>) was gc'd while locked
  warn("%r was gc'd while locked" % self)
o:\src\bazaar\bzr.dev\bzrlib\lock.py:79: UserWarning: lock on <open file u'O:/window~1/testbzr-yoiuv8.tmp/tmp9vrlfb/work/push-b/.bzr/checkout/dirstate', mode 'rb+' at 0x04796EC0> not released
  warn("lock on %r not released" % self.f)
o:\src\bazaar\bzr.dev\bzrlib\lockable_files.py:111: UserWarning: LockableFiles(<bzrlib.transport.local.LocalTransport url=file:///O:/window%7E1/testbzr-yoiuv8.tmp/tmp9vrlfb/work/push-b/.bzr/branch/>) was gc'd while locked
  warn("%r was gc'd while locked" % self)
o:\src\bazaar\bzr.dev\bzrlib\lockable_files.py:111: UserWarning: LockableFiles(<bzrlib.transport.local.LocalTransport url=file:///O:/window%7E1/testbzr-yoiuv8.tmp/tmp9vrlfb/work/push-b/.bzr/repository/>) was gc'd while locked
  warn("%r was gc'd while locked" % self)
"""

and the file handle was closed.

John writes:
> We try to be pretty careful in code to use try/finally whenever opening
> a file. Guessing, I would say these faults tend to be from the test
> suite itself. So knowing what specific tests are failing could help
> avoid the problems.

The test_branch_keeps_signatures test is one example.  I've attached a text file with the partial output from that test - highlights include:

"""
Permission denied: unable to remove testing dir tmpsonq48
o:\src\bazaar\bzr.dev\bzrlib\lockable_files.py:111: UserWarning: LockableFiles(...) was gc'd while locked
  warn("%r was gc'd while locked" % self)
o:\src\bazaar\bzr.dev\bzrlib\lock.py:79: UserWarning: lock on <open file ...>
...
ERROR
  File "o:\src\bazaar\bzr.dev\bzrlib\lock.py", line 278, in _lock
    raise errors.LockContention(filename)
LockContention: Could not acquire lock "O:/window~1/testbzr-jo3oza.tmp/tmpsonq48/work/target/.bzr/checkout/dirstate"
"""

and 'process explorer' tells me the open handle causing the failure to remove the directory is that dirstate file.

Hope this helps,

Mark




More information about the bazaar mailing list