radareorg / radare2-r2pipe

Access radare2 via pipe from any programming language!
388 stars 99 forks source link

Python3 usage example fails with v1.0.0 #82

Closed 0x6A6B closed 5 years ago

0x6A6B commented 5 years ago

I am seeing a failure of the simple usage example when I use v1.0.0 of r2pipe from pip with python3.

Here's what I see:

(tmp) $ python
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import r2pipe
>>> r2pipe.VERSION
'1.0.0'
>>> r2 = r2pipe.open("/bin/ls")
>>> r2.cmd('aa')
<Task finished coro=<open._cmd_process() done, defined at /home/jkimpel/tmp/lib/python3.5/site-packages/r2pipe/open_async.py:95> result=''>
>>> print(r2.cmd("afl"))
<Task finished coro=<open._cmd_process() done, defined at /home/jkimpel/tmp/lib/python3.5/site-packages/r2pipe/open_async.py:95> result=''>
>>> print(r2.cmdj("aflj"))  # evaluates JSONs and returns an object
r2pipe.cmdj.Error: Expecting value: line 1 column 1 (char 0)
None
>>> r2.quit()
>>> quit()
Exception ignored in: <bound method BaseEventLoop.__del__ of <_UnixSelectorEventLoop running=False closed=True debug=False>>
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/base_events.py", line 431, in __del__
  File "/usr/lib/python3.5/asyncio/unix_events.py", line 58, in close
  File "/usr/lib/python3.5/asyncio/unix_events.py", line 139, in remove_signal_handler
  File "/usr/lib/python3.5/signal.py", line 47, in signal
TypeError: signal handler must be signal.SIG_IGN, signal.SIG_DFL, or a callable object
Exception ignored in: <bound method BaseSubprocessTransport.__del__ of <_UnixSubprocessTransport closed pid=7951 running stdin=<_UnixWritePipeTransport closed fd=7 closed> stdout=<_UnixReadPipeTransport closing fd=9 open>>>
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/base_subprocess.py", line 126, in __del__
  File "/usr/lib/python3.5/asyncio/base_subprocess.py", line 101, in close
  File "/usr/lib/python3.5/asyncio/unix_events.py", line 376, in close
  File "/usr/lib/python3.5/asyncio/unix_events.py", line 404, in _close
  File "/usr/lib/python3.5/asyncio/base_events.py", line 497, in call_soon
  File "/usr/lib/python3.5/asyncio/base_events.py", line 506, in _call_soon
  File "/usr/lib/python3.5/asyncio/base_events.py", line 334, in _check_closed
RuntimeError: Event loop is closed

Here's the same test using v0.9.9 (I truncated the results for brevity):

(tmp) $ python
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import r2pipe
>>> r2pipe.VERSION
'0.9.9'
>>> r2 = r2pipe.open("/bin/ls")
>>> r2.cmd('aa')
''
>>> print(r2.cmd("afl"))
0x004022b8    3 26           sym._init
0x004022f0    1 6            sym.imp.__ctype_toupper_loc
...omitting long listing...
0x00413c30    3 41   -> 31   fcn.00413c30
0x00413c5c    1 9            sym._fini
>>> print(r2.cmdj("aflj"))
WARNING: r_anal_fcn_cc: assertion 'result > 0' failed (line 1990)
WARNING: r_anal_fcn_cc: assertion 'result > 0' failed (line 1990)
[{'name': 'sym._init',
...omitting large json...
'cost': 5}]
>>> r2.quit()
>>> quit()

Here are some details of my environment:

$ lsb_release -d
Description:    Ubuntu 16.04.5 LTS
$ python3 --version
Python 3.5.2
$ r2 -version
radare2 3.1.0-git 19774 @ linux-x86-64 git.3.0.1-18-g6941e5b
commit: 6941e5bd6649228024ba9964a2c4cc01a799629f build: 2018-10-23__07:31:58
radare commented 5 years ago

Is this happening with python2 too?

The make test in the repo should be checking this stuff

On 30 Nov 2018, at 12:20, 0x6A6B notifications@github.com wrote:

I am seeing a failure of the simple usage example when I use v1.0.0 of r2pipe from pip with python3.

Here's what I see:

(tmp) $ python Python 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information.

import r2pipe r2pipe.VERSION '1.0.0' r2 = r2pipe.open("/bin/ls") r2.cmd('aa') <Task finished coro=<open._cmd_process() done, defined at /home/jkimpel/tmp/lib/python3.5/site-packages/r2pipe/open_async.py:95> result=''> print(r2.cmd("afl")) <Task finished coro=<open._cmd_process() done, defined at /home/jkimpel/tmp/lib/python3.5/site-packages/r2pipe/open_async.py:95> result=''> print(r2.cmdj("aflj")) # evaluates JSONs and returns an object r2pipe.cmdj.Error: Expecting value: line 1 column 1 (char 0) None r2.quit() quit() Exception ignored in: <bound method BaseEventLoop.del of <_UnixSelectorEventLoop running=False closed=True debug=False>> Traceback (most recent call last): File "/usr/lib/python3.5/asyncio/base_events.py", line 431, in del File "/usr/lib/python3.5/asyncio/unix_events.py", line 58, in close File "/usr/lib/python3.5/asyncio/unix_events.py", line 139, in remove_signal_handler File "/usr/lib/python3.5/signal.py", line 47, in signal TypeError: signal handler must be signal.SIG_IGN, signal.SIG_DFL, or a callable object Exception ignored in: <bound method BaseSubprocessTransport.del of <_UnixSubprocessTransport closed pid=7951 running stdin=<_UnixWritePipeTransport closed fd=7 closed> stdout=<_UnixReadPipeTransport closing fd=9 open>>> Traceback (most recent call last): File "/usr/lib/python3.5/asyncio/base_subprocess.py", line 126, in del File "/usr/lib/python3.5/asyncio/base_subprocess.py", line 101, in close File "/usr/lib/python3.5/asyncio/unix_events.py", line 376, in close File "/usr/lib/python3.5/asyncio/unix_events.py", line 404, in _close File "/usr/lib/python3.5/asyncio/base_events.py", line 497, in call_soon File "/usr/lib/python3.5/asyncio/base_events.py", line 506, in _call_soon File "/usr/lib/python3.5/asyncio/base_events.py", line 334, in _check_closed RuntimeError: Event loop is closed Here's the same test using v0.9.9 (I truncated the results for brevity):

(tmp) $ python Python 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information.

import r2pipe r2pipe.VERSION '0.9.9' r2 = r2pipe.open("/bin/ls") r2.cmd('aa') '' print(r2.cmd("afl")) 0x004022b8 3 26 sym._init 0x004022f0 1 6 sym.imp.__ctype_toupper_loc ...omitting long listing... 0x00413c30 3 41 -> 31 fcn.00413c30 0x00413c5c 1 9 sym._fini print(r2.cmdj("aflj")) WARNING: r_anal_fcn_cc: assertion 'result > 0' failed (line 1990) WARNING: r_anal_fcn_cc: assertion 'result > 0' failed (line 1990) [{'name': 'sym._init', ...omitting large json... 'cost': 5}] r2.quit() quit() Here are some details of my environment:

$ lsb_release -d Description: Ubuntu 16.04.5 LTS $ python3 --version Python 3.5.2 $ r2 -version radare2 3.1.0-git 19774 @ linux-x86-64 git.3.0.1-18-g6941e5b commit: 6941e5bd6649228024ba9964a2c4cc01a799629f build: 2018-10-23__07:31:58 — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

0x6A6B commented 5 years ago

seems to be working okay in python2 in a quick test for me

0x6A6B commented 5 years ago

issue resolved in v1.1.0, thank you!