UnboundLocalError: local variable 'lock_url' in wait_lock

Bug #733136 reported by Ray Fan
34
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
High
Martin Pool
2.3
Fix Released
High
Martin Pool
QBzr
Invalid
Medium
Unassigned
bzr (Ubuntu)
Fix Released
Undecided
Unassigned
Natty
Fix Released
High
Jelmer Vernooij

Bug Description

Attempting to save configuration following installation of 2.3.0-0 on Windows XP ver. 2002 SP 3.

bzr: ERROR: exceptions.UnboundLocalError: local variable 'lock_url' referenced before assignment

Traceback (most recent call last):
  File "C:/Program Files/Bazaar/plugins\qbzr\lib\config.py", line 494, in do_accept
  File "C:/Program Files/Bazaar/plugins\qbzr\lib\config.py", line 488, in save
  File "C:/Program Files/Bazaar/plugins\qbzr\lib\util.py", line 143, in save
  File "bzrlib\lockdir.pyo", line 657, in lock_write
  File "bzrlib\lockdir.pyo", line 625, in wait_lock
UnboundLocalError: local variable 'lock_url' referenced before assignment

bzr 2.3.0 on python 2.6.6 (win32)
arguments: ['C:\\Program Files\\Bazaar\\bzrw.exe', 'qconfig']
encoding: 'cp1252', fsenc: 'mbcs', lang: None
plugins:
  bzrtools C:\Program Files\Bazaar\plugins\bzrtools [2.3.1]
  colo C:\Program Files\Bazaar\plugins\colo [0.2.1]
  explorer C:\Program Files\Bazaar\plugins\explorer [1.1.2]
  fastimport C:\Program Files\Bazaar\plugins\fastimport [0.10.0dev]
  launchpad C:\Program Files\Bazaar\plugins\launchpad [2.3.0]
  loom C:\Program Files\Bazaar\plugins\loom [2.2.1dev]
  netrc_credential_store C:\Program Files\Bazaar\plugins\netrc_credential_store [2.3.0]
  news_merge C:\Program Files\Bazaar\plugins\news_merge [2.3.0]
  pipeline C:\Program Files\Bazaar\plugins\pipeline [1.1.0]
  qbzr C:\Program Files\Bazaar\plugins\qbzr [0.20.0]
  rewrite C:\Program Files\Bazaar\plugins\rewrite [0.6.2dev]
  svn C:\Program Files\Bazaar\plugins\svn [1.0.5dev]
  upload C:\Program Files\Bazaar\plugins\upload [1.0.0]
  xmloutput C:\Program Files\Bazaar\plugins\xmloutput [0.8.7.dev]

Related branches

Revision history for this message
Alexander Belchenko (bialix) wrote :

Based on the traceback the error coming from bzrlib. The lines in qbzr codebase those trigger error basically are:

        self._lock = LockDir(transport, 'lock')
        ...
        self._lock.lock_write()

It's possibly we're using lockdir incorrectly, but I don't see why.

affects: qbzr → bzr
Revision history for this message
Vincent Ladeuil (vila) wrote :

Based on the traceback, bzr fail to report a LockContention, which, for saving a configuration file is pretty weird.

There is a genuine bug in bzr as we try to use lock_url before it's set under ...unclear circumstances.

But there seems to also be a bug in qbzr around the config file saving or at least an already pending lock that shouldn't exist no ?

A reproducing recipe would help all parties involved there...

Changed in bzr:
status: New → Incomplete
Revision history for this message
Ray Fan (notnull) wrote :

I'm a bazaar newbie. Is there any logging that can be enabled or generated files that would be useful? I have attached a zip of the screen shots leading to the error in Bazaar Explorer. What additional information is required for a recipe?

Revision history for this message
Alexander Belchenko (bialix) wrote : Re: [Bug 733136] Re: Internal error saving configuration

Vincent Ladeuil пишет:
> But there seems to also be a bug in qbzr around the config file saving
> or at least an already pending lock that shouldn't exist no ?

The code in qbzr is related to our own config handling wheel.

> A reproducing recipe would help all parties involved there...

Indeed. And we need to see the content of you bazaar/2.0 directory
(modulo any sensitive information)

--
All the dude wanted was his rug back

Revision history for this message
Matt Wilkie (maphew) wrote : Re: Internal error saving configuration

I get the same error message, "bzr: ERROR: exceptions.UnboundLocalError: local variable 'lock_url' referenced before assignment", but when trying to run Pull from Bazaar Explorer, not when saving configuration. Full text:

Run command: bzr pull
bzr: ERROR: exceptions.UnboundLocalError: local variable 'lock_url' referenced before assignment

Traceback (most recent call last):
  File "bzrlib\commands.pyo", line 912, in exception_to_return_code
  File "bzrlib\commands.pyo", line 1112, in run_bzr
  File "bzrlib\commands.pyo", line 690, in run_argv_aliases
  File "bzrlib\commands.pyo", line 705, in run
  File "bzrlib\cleanup.pyo", line 135, in run_simple
  File "bzrlib\cleanup.pyo", line 165, in _do_with_cleanups
  File "C:/Program Files (x86)/Bazaar/plugins\qbzr\lib\commands.py", line 767, in run
  File "C:/Program Files (x86)/Bazaar/plugins\qbzr\lib\subprocess.py", line 888, in run_subprocess_command
  File "bzrlib\commands.pyo", line 1112, in run_bzr
  File "bzrlib\commands.pyo", line 690, in run_argv_aliases
  File "bzrlib\commands.pyo", line 705, in run
  File "bzrlib\cleanup.pyo", line 135, in run_simple
  File "bzrlib\cleanup.pyo", line 165, in _do_with_cleanups
  File "bzrlib\builtins.pyo", line 984, in run
  File "bzrlib\workingtree_4.pyo", line 629, in lock_write
  File "bzrlib\branch.pyo", line 2452, in lock_write
  File "bzrlib\lockable_files.pyo", line 187, in lock_write
  File "bzrlib\lockdir.pyo", line 648, in lock_write
  File "bzrlib\lockdir.pyo", line 616, in wait_lock
UnboundLocalError: local variable 'lock_url' referenced before assignment

bzr 2.2.2 on python 2.6.4 (Windows-post2008Server-6.1.7600)
arguments: ['C:\\Program Files (x86)\\Bazaar\\bzr.exe', 'qsubprocess', '--bencode', 'l4:pulle']
encoding: 'cp1252', fsenc: 'mbcs', lang: None
plugins:
  bzrtools C:\Program Files (x86)\Bazaar\plugins\bzrtools [2.2.0]
  colo C:\Program Files (x86)\Bazaar\plugins\colo [0.1.0]
  explorer C:\Program Files (x86)\Bazaar\plugins\explorer [1.1.1]
  fastimport C:\Program Files (x86)\Bazaar\plugins\fastimport [0.9.0dev]
  launchpad C:\Program Files (x86)\Bazaar\plugins\launchpad [2.2.2]
  loom C:\Program Files (x86)\Bazaar\plugins\loom [2.2.1dev]
  netrc_credential_store C:\Program Files (x86)\Bazaar\plugins\netrc_credential_store [2.2.2]
  news_merge C:\Program Files (x86)\Bazaar\plugins\news_merge [2.2.2]
  pipeline C:\Program Files (x86)\Bazaar\plugins\pipeline [unknown]
  qbzr C:\Program Files (x86)\Bazaar\plugins\qbzr [0.19.2]
  rewrite C:\Program Files (x86)\Bazaar\plugins\rewrite [0.6.1]
  svn C:\Program Files (x86)\Bazaar\plugins\svn [1.0.4]
  upload C:\Program Files (x86)\Bazaar\plugins\upload [1.0.0dev]
  xmloutput C:\Program Files (x86)\Bazaar\plugins\xmloutput [0.8.6]

*** Bazaar has encountered an internal error. This probably indicates a
    bug in Bazaar. You can help us fix it by filing a bug report at
        https://bugs.launchpad.net/bzr/+filebug
    including this traceback and a description of the problem.

Revision history for this message
Matt Wilkie (maphew) wrote :

the repository I'm using is lp:leo-editor. My local working tree is at rev3866, current trunk as of this error is rev3929. I'm generally just a consumer of this project, I rarely contribute code and am just using bzr to track latest developments.

Revision history for this message
Matt Wilkie (maphew) wrote :

>> A reproducing recipe would help all parties involved there...
>
>Indeed. And we need to see the content of you bazaar/2.0 directory
>(modulo any sensitive information)

which directory is this? I don't have a dir of that name under "C:\Program Files (x86)\Bazaar"

Revision history for this message
Ray Fan (notnull) wrote :

Here's the content of the directory found under C:\Documents and Settings\Username\Application Data

Revision history for this message
Chris Krelle (nobodycam) wrote :
Download full text (4.0 KiB)

I get same error on a fresh install with window 7 just changing the username and email address.

bzr: ERROR: exceptions.UnboundLocalError: local variable 'lock_url' referenced before assignment

Traceback (most recent call last):
  File "C:/Program Files/Bazaar/plugins\qbzr\lib\config.py", line 494, in do_accept
  File "C:/Program Files/Bazaar/plugins\qbzr\lib\config.py", line 488, in save
  File "C:/Program Files/Bazaar/plugins\qbzr\lib\util.py", line 157, in save
  File "bzrlib\lockdir.pyo", line 657, in lock_write
  File "bzrlib\lockdir.pyo", line 625, in wait_lock
UnboundLocalError: local variable 'lock_url' referenced before assignment

bzr 2.4b1 on python 2.6.6 (win32)
arguments: ['C:\\Program Files\\Bazaar\\bzrw.exe', 'qconfig']
encoding: 'cp1252', fsenc: 'mbcs', lang: None
plugins:
  bzrtools C:\Program Files\Bazaar\plugins\bzrtools [2.4.0]
  colo C:\Program Files\Bazaar\plugins\colo [0.3.0dev]
  explorer C:\Program Files\Bazaar\plugins\explorer [1.1.3dev]
  fastimport C:\Program Files\Bazaar\plugins\fastimport [0.11.0dev]
  launchpad C:\Program Files\Bazaar\plugins\launchpad [2.4b1]
  loom C:\Program Files\Bazaar\plugins\loom [2.2.1dev]
  netrc_credential_store C:\Program Files\Bazaar\plugins\netrc_credential_store [2.4b1]
  news_merge C:\Program Files\Bazaar\plugins\news_merge [2.4b1]
  pipeline C:\Program Files\Bazaar\plugins\pipeline [1.1.0]
  qbzr C:\Program Files\Bazaar\plugins\qbzr [0.21.0dev]
  rewrite C:\Program Files\Bazaar\plugins\rewrite [0.7.0dev]
  svn C:\Program Files\Bazaar\plugins\svn [1.1.0dev]
  upload C:\Program Files\Bazaar\plugins\upload [1.0.1dev]
  xmloutput C:\Program Files\Bazaar\plugins\xmloutput [0.8.7]

Looking at the log shows this:

Tue 2011-03-29 11:10:55 -0700
0.343 bazaar version: 2.4b1
0.343 bzr arguments: [u'explorer']
0.452 looking for plugins in C:/Users/c/AppData/Roaming/bazaar/2.0/plugins
0.452 looking for plugins in C:/Program Files/Bazaar/plugins
1.045 encoding stdout as osutils.get_user_encoding() 'cp1252'
3.104 loading explorer extensions for clothes ['Bazaar support', 'Register on Launchpad']
3.104 explorer extensions provided by the colo plugin in C:/Program Files/Bazaar/plugins/colo/explorer
10.684 Deprecated function called
Called from:
  File "C:/Program Files/Bazaar/plugins\explorer\lib\app_suite.py", line 120, in lookup
  File "C:/Program Files/Bazaar/plugins\explorer\lib\app_suite.py", line 138, in _lookup_here
  File "C:/Program Files/Bazaar/plugins\explorer\lib\app_suite.py", line 150, in command_to_args

Tue 2011-03-29 11:11:11 -0700
0.312 bazaar version: 2.4b1
0.312 bzr arguments: [u'qconfig']
0.421 looking for plugins in C:/Users/c/AppData/Roaming/bazaar/2.0/plugins
0.421 looking for plugins in C:/Program Files/Bazaar/plugins
0.858 encoding stdout as osutils.get_user_encoding() 'cp1252'

Tue 2011-03-29 11:11:47 -0700

[ 4996] 2011-03-29 11:11:48.605 INFO: tbzrcache running...
[ 4780] 2011-03-29 11:12:07.045 INFO: error removing pending lock: Permission denied: "C:/Users/c/AppData/Roaming/bazaar/2....

Read more...

Revision history for this message
Matt Wilkie (maphew) wrote :

my log shows:

Wed 2011-03-30 08:36:35 -0700
0.050 bazaar version: 2.2.2
0.050 bzr arguments: [u'version']
0.060 looking for plugins in C:/Users/mhwilkie/AppData/Roaming/bazaar/2.0/plugins
0.060 looking for plugins in C:/Program Files (x86)/Bazaar/plugins
0.151 encoding stdout as sys.stdout encoding 'cp850'
0.171 Transferred: 0kB (0.0kB/s r:0kB w:0kB)
0.171 return code 0
690.673 return code 0

Wed 2011-03-30 08:40:14 -0700
0.050 bazaar version: 2.2.2
0.050 bzr arguments: [u'pull']
0.060 looking for plugins in C:/Users/mhwilkie/AppData/Roaming/bazaar/2.0/plugins
0.060 looking for plugins in C:/Program Files (x86)/Bazaar/plugins
0.151 encoding stdout as sys.stdout encoding 'cp850'
0.169 opening working tree 'B:/apps/leo-editor'
29.293 Traceback (most recent call last):
  File "bzrlib\commands.pyo", line 912, in exception_to_return_code
  File "bzrlib\commands.pyo", line 1112, in run_bzr
  File "bzrlib\commands.pyo", line 690, in run_argv_aliases
  File "bzrlib\commands.pyo", line 705, in run
  File "bzrlib\cleanup.pyo", line 135, in run_simple
  File "bzrlib\cleanup.pyo", line 165, in _do_with_cleanups
  File "bzrlib\builtins.pyo", line 984, in run
  File "bzrlib\workingtree_4.pyo", line 629, in lock_write
  File "bzrlib\branch.pyo", line 2452, in lock_write
  File "bzrlib\lockable_files.pyo", line 187, in lock_write
  File "bzrlib\lockdir.pyo", line 648, in lock_write
  File "bzrlib\lockdir.pyo", line 616, in wait_lock
UnboundLocalError: local variable 'lock_url' referenced before assignment

29.295 couldn't find apport bug-reporting library: No module named apport
29.332 Transferred: 0kB (0.0kB/s r:0kB w:0kB)
29.332 return code 4

Revision history for this message
Matt Wilkie (maphew) wrote :

found and attached my "bazaar/2.0" folder

Martin Pool (mbp)
summary: - Internal error saving configuration
+ UnboundLocalError: local variable 'lock_url' in wait_lock
Changed in bzr:
assignee: nobody → Martin Pool (mbp)
importance: Undecided → High
status: Incomplete → In Progress
Revision history for this message
Martin Pool (mbp) wrote :

As jam notes in https://code.launchpad.net/~mbp/bzr/733136-lock_url/+merge/55682 this probably means qbzr is doing something strange, like perhaps trying to update the config from one process while another one holds it open. The fix in bzr should make the error more obvious.

For people still hitting this, looking at the 'info' files inside the lock, and patching the process id in there to their command lines will help.

Changed in qbzr:
importance: Undecided → Medium
status: New → Confirmed
Martin Pool (mbp)
Changed in bzr:
status: In Progress → Fix Released
Revision history for this message
Matt Wilkie (maphew) wrote :

Forgive my ignorance, but how do I find and apply the "Fix Released"?

and in the meantime how do I "patch the process id to the command line"? I have no files named "*info*" in my branch.

thanks!

Revision history for this message
John A Meinel (jameinel) wrote : Re: [Bug 733136] Re: UnboundLocalError: local variable 'lock_url' in wait_lock

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 04/12/2011 07:33 PM, Matt Wilkie wrote:
> Forgive my ignorance, but how do I find and apply the "Fix Released"?
>
> and in the meantime how do I "patch the process id to the command line"?
> I have no files named "*info*" in my branch.
>
> thanks!
>

If you are hitting this, it means there is a lock file currently held.
Which should be somewhere like ~/.bazaar/lock/held/info

The fix Martin made is both in the 2.3 series and in trunk. You can
install the bzr-2.4beta daily from the ppa:
  https://launchpad.net/~bzr/+archive/daily

I believe 2.3 with the fix is scheduled to be packaged in a week or so.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk2kqXIACgkQJdeBCYSNAAMS5wCgwGrRLzQjyGHq2EWWQ6L9aRoP
NPEAoI40P6ysCVe1IyJ9wnJzhEosO6mE
=zyha
-----END PGP SIGNATURE-----

Revision history for this message
Matt Wilkie (maphew) wrote :
Download full text (3.1 KiB)

thanks John. I did install the 2.4 beta (bzr-2.4b1-setup.exe) and there is no change in behaviour.
there is a lock directory at `%appdata%\bazaar\2.0\lock` but it is empty. I kept that dir open in Windows Explorer as I ran 'bzr pull' to see if a file showed briefly during execution, but no.

Here is the latest traceback:
{{{
B:\apps\leo-editor>bzr pull
bzr: ERROR: exceptions.UnboundLocalError: local variable 'lock_url' referenced before assignment

Traceback (most recent call last):
  File "bzrlib\commands.pyo", line 926, in exception_to_return_code
  File "bzrlib\commands.pyo", line 1126, in run_bzr
  File "bzrlib\commands.pyo", line 691, in run_argv_aliases
  File "bzrlib\commands.pyo", line 713, in run
  File "bzrlib\cleanup.pyo", line 135, in run_simple
  File "bzrlib\cleanup.pyo", line 165, in _do_with_cleanups
  File "bzrlib\builtins.pyo", line 1005, in run
  File "bzrlib\workingtree_4.pyo", line 629, in lock_write
  File "bzrlib\branch.pyo", line 2448, in lock_write
  File "bzrlib\lockable_files.pyo", line 187, in lock_write
  File "bzrlib\lockdir.pyo", line 657, in lock_write
  File "bzrlib\lockdir.pyo", line 625, in wait_lock
UnboundLocalError: local variable 'lock_url' referenced before assignment

bzr 2.4b1 on python 2.6.6 (Windows-7-6.1.7600)
arguments: ['bzr', 'pull']
encoding: 'cp1252', fsenc: 'mbcs', lang: None
plugins:
bzrtools 2.4.0
  Various useful commands for working with bzr.
   C:\Program Files (x86)\Bazaar\plugins\bzrtools

colo 0.3.0dev
  Work with colocated branches using current technology.
   C:\Program Files (x86)\Bazaar\plugins\colo

explorer 1.1.3dev
  Version Control for Human Beings.
   C:\Program Files (x86)\Bazaar\plugins\explorer

fastimport 0.11.0dev
  FastImport Plugin
   C:\Program Files (x86)\Bazaar\plugins\fastimport

launchpad 2.4b1
  Launchpad.net integration plugin for Bazaar.
   C:\Program Files (x86)\Bazaar\plugins\launchpad

loom 2.2.1dev
  Loom is a bzr plugin which adds new commands to manage a loom of patches.
   C:\Program Files (x86)\Bazaar\plugins\loom

netrc_credential_store 2.4b1
  Use ~/.netrc as a credential store for authentication.conf.
   C:\Program Files (x86)\Bazaar\plugins\netrc_credential_store

news_merge 2.4b1
  Merge hook for bzr's NEWS file.
   C:\Program Files (x86)\Bazaar\plugins\news_merge

pipeline 1.1.0
  Manage a series of branches as a pipeline.
   C:\Program Files (x86)\Bazaar\plugins\pipeline

qbzr 0.21.0dev
  QBzr - Qt-based frontend for Bazaar
   C:\Program Files (x86)\Bazaar\plugins\qbzr

rewrite 0.7.0dev
  Rebase support.
   C:\Program Files (x86)\Bazaar\plugins\rewrite

svn 1.1.0dev
  Support for Subversion branches
   C:\Program Files (x86)\Bazaar\plugins\svn

upload 1.0.1dev
  Upload a working tree, incrementally.
   C:\Program Files (x86)\Bazaar\plugins\upload

xmloutput 0.8.7
  This plugin adds an option (--xml) to log and provides an xml version of some
builtin commands.
   C:\Program Files (x86)\Bazaar\plugins\xmloutput

*** Bazaar has encountered an internal error. This probably indicates a
    bug in Bazaar. You can help us fix it by filing a bug report at
        https://bugs.launchpad.net/bzr/+filebug
    including this traceback and a description o...

Read more...

Martin Pool (mbp)
Changed in bzr:
milestone: none → 2.4b2
Revision history for this message
Martin Pool (mbp) wrote :

Hi Matt,

This fix was merged after 2.4b1, so you would need to either get a copy of trunk using "bzr branch lp:bzr" or wait for the next Windows beta build.

Jelmer Vernooij (jelmer)
Changed in bzr (Ubuntu):
status: New → Fix Released
Changed in bzr (Ubuntu Natty):
status: New → In Progress
Jelmer Vernooij (jelmer)
Changed in bzr (Ubuntu Natty):
importance: Undecided → High
assignee: nobody → Jelmer Vernooij (jelmer)
Revision history for this message
Martin Pitt (pitti) wrote : Please test proposed package

Accepted bzr into natty-proposed, the package will build now and be available in a few hours. Please test and give feedback here. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you in advance!

Changed in bzr (Ubuntu Natty):
status: In Progress → Fix Committed
tags: added: verification-needed
Revision history for this message
Clint Byrum (clint-fewbar) wrote :

Hello Ray, or anyone else affected,

Accepted bzr into natty-proposed, the package will build now and be available in a few hours. Please test and give feedback here. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you in advance!

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Verified by running the bzr testsuite from the package in a clean natty install.

tags: added: verification-done
removed: verification-needed
Jonathan Riddell (jr)
Changed in qbzr:
status: Confirmed → Invalid
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package bzr - 2.3.4-0ubuntu1

---------------
bzr (2.3.4-0ubuntu1) natty-proposed; urgency=low

  * New upstream release.
   + Fix bzr version number in deprecation warnings. LP: #794960
   + Prevent write attemps on remote branch during "bzr up". LP: #786980
   + Fix conflict handling when two trees involved in a merge have different
     root ids. LP: #805809

bzr (2.3.3-0ubuntu1) natty-proposed; urgency=low

  * New upstream release.
   + Fixes deprecation warning on newer versions of Python. LP: #760435
   + Stops 'bzr push' from copying entire repository if a .bzr directory is
     present without a branch. LP: #465517
   + Fixes undefined local variable error when waiting for lock. LP: #733136
   + Fixes lock contention issues pushing to a bound branch. LP: #733350
   + Transfers less data creating a new stacked branch. LP: #737234
   + Several fixes to the test suite, making it more robust. LP: #654733,
      LP: #751824
   + 'bzr merge --pull --preview' actually shows a preview rather than
     actually merging. LP: #760152
   + bzr smart server now supports UTF-8 user names. LP: #659763
   + user identity can now be set based on username and /etc/mailname, not
     requiring it to be set manually. LP: #616878
   + stacking is now fully transitive. LP: #715000
   + makes in-terminal crash report of plugins much shorter. LP: #716389
 -- Jelmer Vernooij <email address hidden> Thu, 14 Jul 2011 21:12:58 +0200

Changed in bzr (Ubuntu Natty):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Related questions

Remote bug watches

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