Bug 246212

Summary: "pydoc -k searchterm" MemoryError. permission denied.
Product: [Fedora] Fedora Reporter: Jason Farrell <farrellj>
Component: python-pyblockAssignee: Peter Jones <pjones>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: medium    
Version: 12CC: dmalcolm, hdegoede, ivazqueznet, james.antill, nphilipp, rhbugzilla, seth.anil
Target Milestone: ---Keywords: Reopened, Triaged
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2010-01-05 09:38:48 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 467266    

Description Jason Farrell 2007-06-29 08:44:55 UTC
Can't do a clean pydoc search as a normal user because python-pyblock's modules
get in the way with a permission denied during the package walk:

$ pydoc -k foo
/dev/mapper/control: open failed: Permission denied
Failure to communicate with kernel device-mapper driver.
dm.c: 1565
Traceback (most recent call last):
  File "/usr/bin/pydoc", line 5, in <module>
    pydoc.cli()
  File "/usr/lib/python2.5/pydoc.py", line 2183, in cli
    apropos(val)
  File "/usr/lib/python2.5/pydoc.py", line 1881, in apropos
    ModuleScanner().run(callback, key)
  File "/usr/lib/python2.5/pydoc.py", line 1846, in run
    for importer, modname, ispkg in pkgutil.walk_packages():
  File "/usr/lib/python2.5/pkgutil.py", line 110, in walk_packages
    __import__(name)
  File "/usr/lib/python2.5/site-packages/block/__init__.py", line 6, in <module>
    from device import MultiPath, RaidDev, RaidSet, BlockDev, DeviceMaps, \
  File "/usr/lib/python2.5/site-packages/block/device.py", line 190, in <module>
    class MPNameCache(_IUD):
  File "/usr/lib/python2.5/site-packages/block/device.py", line 195, in MPNameCache
    for map in _dm.maps():
MemoryError


$ sudo pydoc -k foo
Data Dir: /usr/share/gnome-applets/invest-applet
04:43:55 config section (pydoc_log) not found

Comment 1 Jason Farrell 2008-01-01 06:24:40 UTC
Can reproduce this in F8 in a slightly different way by running "pydoc -k
keyword" as a normal user in any directory containing files you don't have
permission to read.

$ cd /tmp
$ pydoc -k foo
Traceback (most recent call last):
  File "/usr/bin/pydoc", line 5, in <module>
    pydoc.cli()
  File "/usr/lib/python2.5/pydoc.py", line 2189, in cli
    apropos(val)
  File "/usr/lib/python2.5/pydoc.py", line 1887, in apropos
    ModuleScanner().run(callback, key)
  File "/usr/lib/python2.5/pydoc.py", line 1852, in run
    for importer, modname, ispkg in pkgutil.walk_packages():
  File "/usr/lib/python2.5/pkgutil.py", line 105, in walk_packages
    for importer, name, ispkg in iter_modules(path, prefix):
  File "/usr/lib/python2.5/pkgutil.py", line 147, in iter_modules
    for name, ispkg in iter_importer_modules(i, prefix):
  File "/usr/lib/python2.5/pkgutil.py", line 211, in iter_modules
    for fn in os.listdir(path):
OSError: [Errno 13] Permission denied: './gconfd-root'
$ mkdir asdf && cd asdf
$ pydoc -k foo
Data Dir: /usr/share/gnome-applets/invest-applet
zope.interface.tests.ifoo - IFoo test module

Comment 2 Nils Philippsen 2008-02-14 13:31:41 UTC
James, I've added you to Cc because I think this might warrant a generic
workaround in pydoc -- despite that these modules need being fixed. What do you
think?

Comment 3 Anil Seth 2008-04-06 06:50:59 UTC
On Fedora 8, if the python-pyblock rpm is installed, using 
>>>help() 
help>modules
results in similar error. The trace is given below:

Please wait a moment while I gather a list of all available modules...

/dev/mapper/control: open failed: Permission denied
Failure to communicate with kernel device-mapper driver.
dm.c: 1577
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.5/site.py", line 351, in __call__
    return pydoc.help(*args, **kwds)
  File "/usr/lib64/python2.5/pydoc.py", line 1646, in __call__
    self.interact()
  File "/usr/lib64/python2.5/pydoc.py", line 1664, in interact
    self.help(request)
  File "/usr/lib64/python2.5/pydoc.py", line 1680, in help
    elif request == 'modules': self.listmodules()
  File "/usr/lib64/python2.5/pydoc.py", line 1801, in listmodules
    ModuleScanner().run(callback)
  File "/usr/lib64/python2.5/pydoc.py", line 1852, in run
    for importer, modname, ispkg in pkgutil.walk_packages():
  File "/usr/lib64/python2.5/pkgutil.py", line 110, in walk_packages
    __import__(name)
  File "/usr/lib64/python2.5/site-packages/block/__init__.py", line 23, in <module>
    from device import MultiPath, RaidDev, RaidSet, BlockDev, DeviceMaps, \
  File "/usr/lib64/python2.5/site-packages/block/device.py", line 209, in <module>
    class MPNameCache(_IUD):
  File "/usr/lib64/python2.5/site-packages/block/device.py", line 214, in
MPNameCache
    for map in _dm.maps():
MemoryError


Comment 4 Matteo Castellini 2008-05-23 12:35:34 UTC
I can confirm this bug in python-pyblock (python-pyblock-0.30-1.fc8): pydoc's
packages walk is interrupted and returns a traceback when python-pyblock is
installed. 

It can be always reproduced (as in comment #3) by opening a python shell as a
normal non-root user, entering the online help utility typing "help()" and
trying to get the list of available modules typing "modules".

Steps to Reproduce:
1. $ python
2. >>> help()
3. help> modules

Actual results:
Please wait a moment while I gather a list of all available modules...

/dev/mapper/control: open failed: Permission denied
Failure to communicate with kernel device-mapper driver.
dm.c: 1577
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/site.py", line 346, in __call__
    return pydoc.help(*args, **kwds)
  File "/usr/lib/python2.5/pydoc.py", line 1646, in __call__
    self.interact()
  File "/usr/lib/python2.5/pydoc.py", line 1664, in interact
    self.help(request)
  File "/usr/lib/python2.5/pydoc.py", line 1680, in help
    elif request == 'modules': self.listmodules()
  File "/usr/lib/python2.5/pydoc.py", line 1801, in listmodules
    ModuleScanner().run(callback)
  File "/usr/lib/python2.5/pydoc.py", line 1852, in run
    for importer, modname, ispkg in pkgutil.walk_packages():
  File "/usr/lib/python2.5/pkgutil.py", line 110, in walk_packages
    __import__(name)
  File "/usr/lib/python2.5/site-packages/block/__init__.py", line 23, in <module>
    from device import MultiPath, RaidDev, RaidSet, BlockDev, DeviceMaps, \
  File "/usr/lib/python2.5/site-packages/block/device.py", line 209, in <module>
    class MPNameCache(_IUD):
  File "/usr/lib/python2.5/site-packages/block/device.py", line 214, in MPNameCache
    for map in _dm.maps():
MemoryError

Comment 5 Bug Zapper 2008-11-26 07:23:06 UTC
This message is a reminder that Fedora 8 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 8.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '8'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 8's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 8 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 6 Nils Philippsen 2008-11-26 09:56:03 UTC
This problem is still present with:

python-pyblock-0.32-1.fc10.x86_64
python-2.5.2-1.fc10.x86_64

James, what is your opinion about this? Can this issue be worked around in pydoc (e.g. by catching import errors) and/or should modules in the default search path always be importable without throwing exceptions or at least never do things on import that require special permissions?

Comment 7 Ignacio Vazquez-Abrams 2008-11-26 10:13:05 UTC
MemoryError should never be caught. If it gets thrown then there is something *very* wrong in the code.

Why exactly does _dm.maps() return a sequence that long?

Comment 8 Nils Philippsen 2008-12-01 13:18:26 UTC
(In reply to comment #7)
> MemoryError should never be caught. If it gets thrown then there is something
> *very* wrong in the code.
> 
> Why exactly does _dm.maps() return a sequence that long?

As far as I can say, the MemoryError here is a permissions issue, it's not indicating lack of available memory.

Comment 9 Bug Zapper 2009-11-18 08:12:18 UTC
This message is a reminder that Fedora 10 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 10.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '10'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 10's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 10 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 10 Jason Farrell 2009-11-18 17:59:31 UTC
searching help still barfs out of the f12 box.
python-2.6.2-2.fc12.i686

$ pydoc -k foo
dm.c: 1640: not running as root returning empty list
Traceback (most recent call last):
  File "/usr/bin/pydoc", line 5, in <module>
    pydoc.cli()
  File "/usr/lib/python2.6/pydoc.py", line 2264, in cli
    apropos(val)
  File "/usr/lib/python2.6/pydoc.py", line 1962, in apropos
    ModuleScanner().run(callback, key)
  File "/usr/lib/python2.6/pydoc.py", line 1927, in run
    for importer, modname, ispkg in pkgutil.walk_packages(onerror=onerror):
  File "/usr/lib/python2.6/pkgutil.py", line 110, in walk_packages
    __import__(name)
  File "/usr/lib/python2.6/site-packages/parted/__init__.py", line 28, in <module>
    from _ped import AlignmentException
RuntimeError: pyparted requires root access

Comment 11 Dave Malcolm 2009-12-02 20:55:42 UTC
See also bug 461419, which is now a general 'make "pydoc -k" more robust' bug.

Comment 12 Hans de Goede 2010-01-05 09:38:48 UTC
This has been fixed for pyblock for a while now, the traceback shown in
comment #10 comes from pyparted, not pyblock.

Note that the pyparted issue has also been fixed in rawhide, closing this.