Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

attach(): AttributeError: 'module' object has no attribute 'poll' #14

Open
vortec opened this issue Mar 31, 2014 · 6 comments
Open

attach(): AttributeError: 'module' object has no attribute 'poll' #14

vortec opened this issue Mar 31, 2014 · 6 comments
Labels

Comments

@vortec
Copy link

vortec commented Mar 31, 2014

When I try to attach to a Python process, I get the following traceback (OSX 10.9.2):

>>> attach(3938)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/opt/cate2/instances/testenv/lib/python2.7/site-packages/pyringe/repl.py", line 157, in Attach
    self.inferior.Reinit(pid)
  File "/opt/cate2/instances/testenv/lib/python2.7/site-packages/pyringe/inferior.py", line 418, in Reinit
    self.__init__(pid, auto_symfile_loading)
  File "/opt/cate2/instances/testenv/lib/python2.7/site-packages/pyringe/inferior.py", line 390, in __init__
    self.StartGdb()
  File "/opt/cate2/instances/testenv/lib/python2.7/site-packages/pyringe/inferior.py", line 436, in StartGdb
    self._gdb = GdbProxy()
  File "/opt/cate2/instances/testenv/lib/python2.7/site-packages/pyringe/inferior.py", line 166, in __init__
    self._poller = select.poll()
AttributeError: 'module' object has no attribute 'poll'
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/opt/cate2/instances/testenv/lib/python2.7/site-packages/pyringe/__main__.py", line 19, in <module>
    pyringe.interact()
  File "/opt/cate2/instances/testenv/lib/python2.7/site-packages/pyringe/__init__.py", line 25, in interact
    DebuggingConsole().interact()
  File "/opt/cate2/instances/testenv/lib/python2.7/site-packages/pyringe/repl.py", line 208, in interact
    prompt = self.StatusLine() + '\n' + sys.ps1
  File "/opt/cate2/instances/testenv/lib/python2.7/site-packages/pyringe/repl.py", line 133, in StatusLine
    self.inferior.StartGdb()
  File "/opt/cate2/instances/testenv/lib/python2.7/site-packages/pyringe/inferior.py", line 436, in StartGdb
    self._gdb = GdbProxy()
  File "/opt/cate2/instances/testenv/lib/python2.7/site-packages/pyringe/inferior.py", line 166, in __init__
    self._poller = select.poll()
AttributeError: 'module' object has no attribute 'poll'

GDB is installed (6.3.50).

@TehMillhouse
Copy link
Contributor

It looks like the poll system call exists on OS X, but its implementation is so broken that they disabled it in the select python module. The canonical replacement for select.poll seems to be select.kqueue, but that's BSD-specific and won't work on Linux.

Properly fixing #4 would probably remove our use of select.poll and eliminate this issue altogether.

@sandlbn
Copy link

sandlbn commented Mar 31, 2014

HI It's work with kqueue. I will try to push changes to master on evening. With this change pyringe works booth on mac os and linux.

@TehMillhouse
Copy link
Contributor

As kqueue is BSD-specific and Linux isn't a BSD derivative, kqueue doesn't exist on linux:

>>> import select
>>> select.kqueue
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'kqueue'

I haven't seen the code, but unless you want to lock out Linux users you'd have to supply two alternate implementations of the tempfile-based IPC.
As an alternative, I propose factoring out the approach already seen in payloads/exec_socket.py into something all parts of the debugger can use.
That would fix issue #4, #14, make resolving #2 a lot easier, and would do away with tempfile-based IO.

@mcscope
Copy link

mcscope commented Oct 3, 2014

Did this ever come to a resolution? I'd like to use pyringe on osx.
PS I just this evening received the same bug (no attribute poll)

@TehMillhouse
Copy link
Contributor

It hasn't so far. "Properly" fixing this means rewriting the IPC mechanism used for communicating with gdb, and it's not likely I'll get around to doing that.

The system build of python on os x just doesn't supply the poll interface. The build provided by macports does, however from what people say its semantics are different. So using the macports build of python may let you work around this issue for the time being.

@mcscope
Copy link

mcscope commented Oct 3, 2014

Thanks for the tip. I recompiled my python with --with-poll and I got pyringe to connect.
Thanks for maintaining this repo!
Here's how I did it, for future readers:

brew install python --with-poll

I also had to run

sudo python -m pyringe

to get around the gdb code signing error, although I think there is another way around this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants