UnboundLocalError 'changed' in _dirstate_helpers_pyx _loop_one_block at initial commit

Bug #850303 reported by pgnd
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
Invalid
Undecided
Unassigned
2.4
Confirmed
Low
Unassigned
bzr (Debian)
New
Undecided
Unassigned

Bug Description

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

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/bzrlib/commands.py", line 946, in exception_to_return_code
    return the_callable(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/bzrlib/commands.py", line 1150, in run_bzr
    ret = run(*run_argv)
  File "/usr/local/lib/python2.7/site-packages/bzrlib/commands.py", line 699, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/usr/local/lib/python2.7/site-packages/bzrlib/commands.py", line 721, in run
    return self._operation.run_simple(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/bzrlib/cleanup.py", line 135, in run_simple
    self.cleanups, self.func, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/bzrlib/cleanup.py", line 165, in _do_with_cleanups
    result = func(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/bzrlib/builtins.py", line 3316, in run
    lossy=lossy)
  File "/usr/local/lib/python2.7/site-packages/bzrlib/decorators.py", line 217, in write_locked
    result = unbound(self, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/bzrlib/workingtree_4.py", line 209, in commit
    result = WorkingTree.commit(self, message, revprops, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/bzrlib/decorators.py", line 217, in write_locked
    result = unbound(self, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/bzrlib/mutabletree.py", line 210, in commit
    *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/bzrlib/commit.py", line 289, in commit
    lossy=lossy)
  File "/usr/local/lib/python2.7/site-packages/bzrlib/cleanup.py", line 131, in run
    self.cleanups, self.func, self, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/bzrlib/cleanup.py", line 165, in _do_with_cleanups
    result = func(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/bzrlib/commit.py", line 425, in _commit
    self._update_builder_with_changes()
  File "/usr/local/lib/python2.7/site-packages/bzrlib/commit.py", line 661, in _update_builder_with_changes
    self.work_tree, self.basis_revid, iter_changes):
  File "/usr/local/lib/python2.7/site-packages/bzrlib/vf_repository.py", line 634, in record_iter_changes
    for change in iter_changes:
  File "/usr/local/lib/python2.7/site-packages/bzrlib/commit.py", line 682, in _filter_iter_changes
    for change in iter_changes:
  File "_dirstate_helpers_pyx.pyx", line 1459, in bzrlib._dirstate_helpers_pyx.ProcessEntryC.__next__ (bzrlib/_dirstate_helpers_pyx.c:12037)
  File "_dirstate_helpers_pyx.pyx", line 1732, in bzrlib._dirstate_helpers_pyx.ProcessEntryC._iter_next (bzrlib/_dirstate_helpers_pyx.c:14786)
  File "_dirstate_helpers_pyx.pyx", line 1888, in bzrlib._dirstate_helpers_pyx.ProcessEntryC._loop_one_block (bzrlib/_dirstate_helpers_pyx.c:16487)
UnboundLocalError: local variable 'changed' referenced before assignment

bzr 2.4.2dev on python 2.7.0 (Linux-2.6.37.6-0.7-xen-i686-with-SuSE-11.4-i586)
arguments: ['/usr/local/bin/bzr', 'commit', '-m', 'Initial commit after mv to
    site-subdir']
plugins: bash_completion[2.4.2dev], bzrtools[2.4.0],
    changelog_merge[2.4.2dev], launchpad[2.4.2dev],
    netrc_credential_store[2.4.2dev], news_merge[2.4.2dev],
    weave_fmt[2.4.2dev]
encoding: 'UTF-8', fsenc: 'UTF-8', lang: 'en_US.UTF-8'

*** 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.

fyi, this is

bzr --version
Bazaar (bzr) 2.4.2dev
  Python interpreter: /usr/bin/python 2.7.0
  Python standard library: /usr/lib/python2.7
  Platform: Linux-2.6.37.6-0.7-xen-i686-with-SuSE-11.4-i586
  bzrlib: /usr/local/lib/python2.7/site-packages/bzrlib
  Bazaar configuration: /root/.bazaar
  Bazaar log file: /root/.bzr.log

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

It's not obvious to me how it could get to that line without 'changed' being assigned up front. If you installed from source, you might want to check that you have rebuild the extension modules.

summary: - bzr 24-dev crash (exceptions.UnboundLocalError) at initial commit
+ UnboundLocalError 'changed' in _dirstate_helpers_pyx _loop_one_block at
+ initial commit
Changed in bzr:
status: New → Incomplete
Revision history for this message
pgnd (pgnd) wrote :
Download full text (5.4 KiB)

well this is odd. looks like something IN the dir?

starting clean with fresh src,

cd /usr/local/src/bzr24
bzr info
 Standalone tree (format: 2a)
 Location:
   branch root: .

 Related branches:
   parent branch: bzr+ssh://bazaar.launchpad.net/%2Bbranch/bzr/2.4/

bzr log | head -n 8
 ------------------------------------------------------------
 revno: 6046 [merge]
 committer: Patch Queue Manager <email address hidden>
 branch nick: 2.4
 timestamp: Mon 2011-09-12 12:35:20 +0000
 message:
   (jelmer) Allow the uses of spaces in merge tools paths. (Gordon Tyler)
 ------------------------------------------------------------

ls -ald /usr/local/lib/python2.7/site-packages/bzrlib
 /bin/ls: cannot access /usr/local/lib/python2.7/site-packages/bzrlib: No such file or directory

make
python setup.py install

ls -ald /usr/local/lib/python2.7/site-packages/bzrlib
 drwxr-xr-x 17 root root 12288 Sep 14 16:45 /usr/local/lib/python2.7/site-packages/bzrlib/

cd /usr/local/lib/python2.7/site-packages/bzrlib
ls -ald *
 drwxr-xr-x 3 root root 4096 Sep 14 16:45 bash_completion/
 drwxr-xr-x 3 root root 4096 Sep 14 16:45 changelog_merge/
 -rw-r--r-- 1 root root 771 Sep 14 10:18 __init__.py
 -rw-r--r-- 1 root root 198 Sep 14 16:45 __init__.pyc
 drwxr-xr-x 2 root root 4096 Sep 14 16:45 launchpad/
 drwxr-xr-x 3 root root 4096 Sep 14 16:45 netrc_credential_store/
 drwxr-xr-x 3 root root 4096 Sep 14 16:45 news_merge/
 drwxr-xr-x 2 root root 4096 Sep 14 16:45 weave_fmt/

bzr init ~/test-dir
 Created a standalone tree (format: 2a)
cd ~/test-dir
touch test.txt
bzr add
 adding test.txt

bzr commit -m "test"
 Committing to: /root/test-dir/
 added test.txt
 Committed revision 1.

cd /srv/www/site03
bzr init
 Created a standalone tree (format: 2a)
bzr add

bzr commit -m "test"
...
added main/sites/all/libraries
bzr: ERROR: exceptions.UnboundLocalError: local variable 'changed' referenced before assignment

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/bzrlib/commands.py", line 946, in exception_to_return_code
    return the_callable(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/bzrlib/commands.py", line 1150, in run_bzr
    ret = run(*run_argv)
  File "/usr/local/lib/python2.7/site-packages/bzrlib/commands.py", line 699, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/usr/local/lib/python2.7/site-packages/bzrlib/commands.py", line 721, in run
    return self._operation.run_simple(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/bzrlib/cleanup.py", line 135, in run_simple
    self.cleanups, self.func, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/bzrlib/cleanup.py", line 165, in _do_with_cleanups
    result = func(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/bzrlib/builtins.py", line 3316, in run
    lossy=lossy)
  File "/usr/local/lib/python2.7/site-packages/bzrlib/decorators.py", line 217, in write_locked
    result = unbound(self, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/bzrlib/workingtree_4.py", line 209, in commit
    result = WorkingTree.commit(self, message, revprops, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-p...

Read more...

Revision history for this message
Martin Pool (mbp) wrote : Re: [Bug 850303] Re: UnboundLocalError 'changed' in _dirstate_helpers_pyx _loop_one_block at initial commit

On 15 September 2011 09:59, pgnet <email address hidden> wrote:
> cd /usr/local/lib/python2.7/site-packages/bzrlib
> ls -ald *
>        drwxr-xr-x 3 root root 4096 Sep 14 16:45 bash_completion/
>        drwxr-xr-x 3 root root 4096 Sep 14 16:45 changelog_merge/
>        -rw-r--r-- 1 root root  771 Sep 14 10:18 __init__.py
>        -rw-r--r-- 1 root root  198 Sep 14 16:45 __init__.pyc
>        drwxr-xr-x 2 root root 4096 Sep 14 16:45 launchpad/
>        drwxr-xr-x 3 root root 4096 Sep 14 16:45 netrc_credential_store/
>        drwxr-xr-x 3 root root 4096 Sep 14 16:45 news_merge/
>        drwxr-xr-x 2 root root 4096 Sep 14 16:45 weave_fmt/

this is strange. where are the rest of the files?

Revision history for this message
pgnd (pgnd) wrote :

that's just a list of the dirs for the plugins referenced in the traceback,

  ...
  plugins: bash_completion[2.4.2dev], changelog_merge[2.4.2dev],
      launchpad[2.4.2dev], netrc_credential_store[2.4.2dev],
      news_merge[2.4.2dev], weave_fmt[2.4.2dev]
  ...

I can provide a list of anything you need to see.

fyi, switching instead to:

bzr --version
Bazaar (bzr) 2.5.0dev1
  Python interpreter: /usr/bin/python 2.7.0
  Python standard library: /usr/lib/python2.7
  Platform: Linux-2.6.37.6-0.7-xen-i686-with-SuSE-11.4-i586
  bzrlib: /usr/local/lib/python2.7/site-packages/bzrlib
  Bazaar configuration: /root/.bazaar
  Bazaar log file: /root/.bzr.log

and repeating the above experiment, NO problem at commit.

and, for reference, @ switch back to 2.4-dev, and the problem returns.

Revision history for this message
pgnd (pgnd) wrote :

just caught my typo above ... that's

cd /usr/local/lib/python2.7/site-packages/bzrlib/plugins
ls -ald *

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

could this be related to bug 837221? it doesn't look exactly the same but perhaps it's a cython/pyrex quirk.

interesting that it's reliable on trunk and not on 2.5

Revision history for this message
pgnd (pgnd) wrote :

hm, possibly ....

rpm -qa | egrep -i "cython|pyrex"
 pyrex-0.9.9-12.1.i586
 python-Cython-0.15-8.1.i586

I'll see if I can downgrade cython ... but, 1st quick question: are BOTh cython and pyrex prereqs? iirc (i'll get to the docs here in a sec), cython is not required. or?

Revision history for this message
pgnd (pgnd) wrote :

completely rm'ing cython doesn't seem to matter for version 24-dev.

rpm -e python-Cython-0.15-8.1.i586
cd /usr/local/src/bzr24
make clean
make
 ...
 No Cython, trying Pyrex...
 ...
python setup.py install
cd /srv/www/site03
bzr init
 Created a standalone tree (format: 2a)
bzr add
bzr commit -m "test"

... same backtrace as above ...

Revision history for this message
pgnd (pgnd) wrote :

and, after reinstalling a downgraded cython, python-cython-0.12.1-2.3.i586, version 24-dev gives the same backtrace again.

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

Could you attach the built _pyx.c file?

Revision history for this message
pgnd (pgnd) wrote :

> Could you attach the built _pyx.c file?

There's no such file I can find.

cd /usr/local/src/bzr24
make clean
make
python setup.py build
find . | grep -i pyx

      --> http://pastebin.com/irM91NG3

which of those file(s) would you like?

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

./bzrlib/_dirstate_helpers_pyx.c please

Revision history for this message
pgnd (pgnd) wrote :

> bzrlib/_dirstate_helpers_pyx.c

per reuqest, attached

pgnd (pgnd)
Changed in bzr:
status: Incomplete → New
Revision history for this message
John A Meinel (jameinel) wrote :

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

On 9/15/2011 6:41 AM, pgnet wrote:
>> Could you attach the built _pyx.c file?
>
> There's no such file I can find.
>
> cd /usr/local/src/bzr24 make clean make python setup.py build find
> . | grep -i pyx
>
> --> http://pastebin.com/irM91NG3
>
> which of those file(s) would you like?
>

I don't think make clean actually does the right thing with generated
pyx.c files. You'll want:

rm bzrlib/*.c bzrlib/*.so
bzr revert # to restore some .c files we actually keep
make

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk5zSPQACgkQJdeBCYSNAAOD1wCfcL3NzdawlxR8KIQFhnge/Y6Y
hrwAnA2D4fMnAGq8bNZJ90nbn8BpMJI0
=Eywm
-----END PGP SIGNATURE-----

Revision history for this message
pgnd (pgnd) wrote :

just in case,

cd /usr/local/src/bzr24
 rm bzrlib/*.c bzrlib/*.so
 bzr revert
 make
 python setup.py install

find . | grep -i pyx
 --> http://pastebin.com/8W9qN3TT

cd /srv/www/site03
bzr init
 Created a standalone tree (format: 2a)
bzr add
bzr commit -m "test"

...
UnboundLocalError: local variable 'changed' referenced before assignment

bzr 2.4.2dev on python 2.7.0 (Linux-2.6.37.6-0.7-xen-i686-with-SuSE-11.4-i586)
arguments: ['/usr/local/bin/bzr', 'commit', '-m', 'test']
plugins: bash_completion[2.4.2dev], changelog_merge[2.4.2dev],
    launchpad[2.4.2dev], netrc_credential_store[2.4.2dev],
    news_merge[2.4.2dev], weave_fmt[2.4.2dev]
encoding: 'UTF-8', fsenc: 'UTF-8', lang: 'en_US.UTF-8'

*** 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.

doesn't seem to make any noticeable difference.

Revision history for this message
Martin Packman (gz) wrote :

There's also `make realclean` that was added to resolve the issue of removing tarball distributed but pyrex generated files. It only deletes a couple of header files in addition to John's method though so shouldn't make any difference here.

Revision history for this message
pgnd (pgnd) wrote :

since I hadn't reported yet, building 2.4.1 release tarballt,

 cd /srv/www/site03
 ...
 bzr commit -m "test"bzr
  Committed revision 1.

so far, it's just the 2.4-dev branch that's got issues. the trunk branch, and the 2.4.1 release tarball are ok.

Revision history for this message
John A Meinel (jameinel) wrote :

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

On 9/17/2011 6:24 PM, pgnet wrote:
> since I hadn't reported yet, building 2.4.1 release tarballt,
>
> cd /srv/www/site03 ... bzr commit -m "test"bzr Committed revision
> 1.
>
> so far, it's just the 2.4-dev branch that's got issues. the trunk
> branch, and the 2.4.1 release tarball are ok.
>

The release tarball should come with pre-generated .c files, generated
with something that isn't cython 0.15.

It is a known issue that cython 0.15 changed how variables were
initialized. Previously, all variables were default initialized to
0/NULL/None (as appropriate). They changed it to stop doing so, which
means our code needs to be audited to put those back in.

If you compile with Cython 0.15+, it should give you warnings about
non-initialized variables. I just haven't had the time to look into
all of them. Unfortunately, older versions of pyrex don't support:

cdef object var = None

So you have to do:

cdef object var
...
var = None

To be compatible across the supported versions of pyrex + cython.

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

iEYEARECAAYFAk53QPYACgkQJdeBCYSNAANwqQCfY++jqeRUNV42M9ainLmxLncT
+qAAn3bD54dCc4HOCaBnH6bCVWBYJdKv
=o9Ym
-----END PGP SIGNATURE-----

Revision history for this message
pgnd (pgnd) wrote :

I'm not entirely clear about your coment's point.

Just to summarize, doing:

 make
 python setup.py.install
 cd /myrepo
 bzr init
 bzr add
 bzr commit -m "test"

in each of three installed-pkg cases:

(i) pyrex-0.9.9-12.1.i586
    (no cython)

(ii) python-Cython-0.15-8.1.i586
    pyrex-0.9.9-12.1.i586

(iii) python-cython-0.12.1-2.3.i586
    pyrex-0.9.9-12.1.i586

for each of:

 bzr-trunk -> commit succeeds
 bzr 2.4-dev -> commit FAILS
 bzr 2.4.1. tarball -> commit succeeds

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

Thanks for the clear summary in #19

Jelmer recently committed

------------------------------------------------------------
revno: 6118 [merge]
committer: Canonical.com Patch Queue Manager <email address hidden>
branch nick: +trunk
timestamp: Thu 2011-09-01 08:46:18 +0000
message:
  (jelmer) Some compatibility fixes for cython.dev. (Denys Duchier)
diff:
=== modified file 'bzrlib/_dirstate_helpers_pyx.pyx'
--- bzrlib/_dirstate_helpers_pyx.pyx 2011-04-22 14:12:22 +0000
+++ bzrlib/_dirstate_helpers_pyx.pyx 2011-08-30 14:45:41 +0000
@@ -1793,6 +1793,7 @@
                 advance_entry = -1
                 advance_path = -1
                 result = None
+ changed = None
                 path_handled = 0
                 if current_entry is None:
                     # unversioned - the check for path_handled when the path

That change isn't in 2.4.

So I think the explanations are:

> bzr-trunk -> commit succeeds

because it has the recent-cython fix

> bzr 2.4-dev -> commit FAILS

does not have the fix

> bzr 2.4.1. tarball -> commit succeeds

doesn't have the fix, but the .c file is shipped so it's not a problem.

So the options now are:
 * you run either 2.5beta or a 2.4 release and we close the bug
 * we merge the patch into 2.4 - it's a small patch, but on the other hand it's a bit of an edge case to work around an apparent cython bug

Changed in bzr:
status: New → Invalid
Revision history for this message
Martin Pool (mbp) wrote :

the task manipulations reflect that i don't think this needs a fix in trunk but it could be fixed in 2.4

Revision history for this message
Martin Packman (gz) wrote :

It seems we already had a bug entry for the fix on 2.5 that got overlooked.

Changed in bzr (Debian):
importance: Unknown → Undecided
status: Unknown → New
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.