_readdir_pyx.pyx in python 2.5 causes errors with bzr

Bug #279381 reported by Joey Stanford
10
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
High
Martin Pool

Bug Description

Intrepid beta, 64bit

Linux c14n 2.6.27-5-generic #1 SMP Fri Oct 3 00:36:38 UTC 2008 x86_64 GNU/Linux

joey@c14n:~/canonical/lp-branches/registryuifixes$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu intrepid (development branch)
Release: 8.10
Codename: intrepid

joey@c14n:~/canonical/lp-branches/registryuifixes$ bzr version
Bazaar (bzr) 1.7.1
  Python interpreter: /usr/bin/python 2.5.2
  Python standard library: /usr/lib/python2.5
  bzrlib: /usr/lib/python2.5/site-packages/bzrlib
  Bazaar configuration: /home/joey/.bazaar
  Bazaar log file: /home/joey/.bzr.log

0.149 encoding stdout as sys.stdout encoding 'UTF-8'
0.152 bzr arguments: [u'-Dhpss', u'info', u'-v']
0.152 looking for plugins in /home/joey/.bazaar/plugins
0.829 looking for plugins in /usr/lib/python2.5/site-packages/bzrlib/plugins
0.829 Plugin name __init__ already loaded
0.829 Plugin name upload already loaded
0.829 Plugin name __init__ already loaded
0.829 Plugin name stats already loaded
0.925 encoding stdout as sys.stdout encoding 'UTF-8'
1.255 opening working tree '/home/joey/canonical/lp-branches/registryuifixes'
1.581 Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 857, in run_bzr_catch_errors
    return run_bzr(argv)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 797, in run_bzr
    ret = run(*run_argv)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 499, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 818, in ignore_pipe
    result = func(*args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/builtins.py", line 1076, in run
    verbose=noise_level, outfile=self.outf)
  File "/usr/lib/python2.5/site-packages/bzrlib/info.py", line 346, in show_bzrdir_info
    outfile)
  File "/usr/lib/python2.5/site-packages/bzrlib/info.py", line 375, in show_component_info
    _show_working_stats(working, outfile)
  File "/usr/lib/python2.5/site-packages/bzrlib/info.py", line 243, in _show_working_stats
    delta = working.changes_from(basis, want_unchanged=True)
  File "/usr/lib/python2.5/site-packages/bzrlib/tree.py", line 94, in changes_from
    want_unversioned=want_unversioned,
  File "/usr/lib/python2.5/site-packages/bzrlib/decorators.py", line 138, in read_locked
    result = unbound(self, *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/tree.py", line 784, in compare
    want_unversioned=want_unversioned)
  File "/usr/lib/python2.5/site-packages/bzrlib/delta.py", line 217, in _compare_trees
    want_unversioned=want_unversioned):
  File "/usr/lib/python2.5/site-packages/bzrlib/workingtree_4.py", line 2307, in iter_changes
    current_dir_info = dir_iterator.next()
  File "/usr/lib/python2.5/site-packages/bzrlib/osutils.py", line 1299, in _walkdirs_fs_utf8
    for _, name in sorted(_listdir(top)):
  File "_readdir_pyx.pyx", line 101, in _readdir_pyx.read_dir
OSError: [Errno 17] File exists

Doing this fixes it:

 sudo mv /usr/lib/python2.5/site-packages/bzrlib/_readdir_pyx.so /usr/lib/python2.5/site-packages/bzrlib/_readdir_pyx.so-old

Joey Stanford (joey)
description: updated
Revision history for this message
Joey Stanford (joey) wrote :
Revision history for this message
Robert Collins (lifeless) wrote :

appears to be a misuse of errno; - need to set to zero before calling every C library call. Yay.

Changed in bzr:
status: New → Confirmed
Revision history for this message
Martin Pool (mbp) wrote : Re: [Bug 279381] Re: _readdir_pyx.pyx in python 2.5 causes errors with bzr

On Tue, Oct 7, 2008 at 11:36 AM, Robert Collins
<email address hidden> wrote:
> appears to be a misuse of errno; - need to set to zero before calling
> every C library call. Yay.

No, that's wrong. Instead, you should only examine errno if the call
returns -1 (or whatever else that particular routine returns.)

--
Martin <http://launchpad.net/~mbp/>

Revision history for this message
Andrew Bennetts (spiv) wrote :

(As an aside, it appears from that strace Python is trying to rewrite the .pyc file for bzrlib/revisiontree.py, but can't because it doesn't have permission to write to /usr/lib. i.e. Python thinks it needs to recompile the .py files in the system-wide bzrlib. That seems like a bug in either the system-wide install of bzr or perhaps Python itself, and will probably be having a significant performance impact on bzr.)

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

> you should only examine errno if the call
> returns -1 (or whatever else that particular routine returns.)

This is generally true, because some libc routines trample errno even if they succeed. However, readdir returns NULL for both EOF and error, and so may require us to set errno first.

http://www.opengroup.org/onlinepubs/009695399/functions/readdir.html
http://thekingant.livejournal.com/83908.html

Revision history for this message
Martin Pool (mbp) wrote :
Changed in bzr:
assignee: nobody → mbp
importance: Undecided → High
status: Confirmed → In Progress
Revision history for this message
Robert Collins (lifeless) wrote : Re: [Bug 279381] Re: _readdir_pyx.pyx in python 2.5 causes errors with bzr

On Tue, 2008-10-07 at 00:59 +0000, Martin Pool wrote:
> On Tue, Oct 7, 2008 at 11:36 AM, Robert Collins
> <email address hidden> wrote:
> > appears to be a misuse of errno; - need to set to zero before calling
> > every C library call. Yay.
>
> No, that's wrong. Instead, you should only examine errno if the call
> returns -1 (or whatever else that particular routine returns.)

man 3 readdir

you have to examine errno when it returns NULL, and NULL does not imply
an error.

My statement was too brief it appears; it should be 'need to set to zero
before calling every C library call that does not unambiguously signal
error'.

-Rob

--
GPG key available at: <http://www.robertcollins.net/keys.txt>.

Revision history for this message
Dan Watkins (oddbloke) wrote :

Fixed in bzr.dev r3767.

Changed in bzr:
status: In Progress → Fix Released
Revision history for this message
Martin Pool (mbp) wrote :

Joey confirms this is fixed.

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

Remote bug watches

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