Open sdt27 opened 2 years ago
Here is a horrible work around :)
There seems to be an extra null-byte in the pipe at the start of the r2 process ?
That's not a good work around, things are failing randomly due to these null bytes long after the pipe is opened.
Apparently changing zro = foo.find(b"\x00")
to zro = foo.rfind(b"\x00")
on _cmd_process(self, cmd)
at open_sync.py
solves the issue.
The first message after spawning r2 its a null byte. The rest of messages do not have this. So an rfind should break other things. I cant repro on linux/mac.
On Fri, 28 Jan 2022 at 23:14, Filipe R. Côgo @.***> wrote:
Apparently changing zro = foo.find(b"\x00") to zro = foo.rfind(b"\x00") on _cmd_process(self, cmd) at open_sync.py solves the issue.
— Reply to this email directly, view it on GitHub https://github.com/radareorg/radare2-r2pipe/issues/146#issuecomment-1024692356, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAG75FRHOQJWVRFJK5RBK3DUYMIMJANCNFSM5L6CC6NA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you are subscribed to this thread.Message ID: @.***>
-- --pancake
I had the same issue, and it seems that it's not only the first message after spawn that has a null byte - every command return started with \x00. I added a check after foo.read
for this and it seemed to solve the issue
if os.name == "nt":
if len(foo) > 1 and foo.startswith(b"\x00"):
foo = foo[1:]
Can you send a pullrequest instead?
On 25 Apr 2022, at 18:11, stiv-kupchik @.***> wrote:
I had the same issue, and it seems that it's not only the first message after spawn that has a null byte - every command return started with \x00. I added a check after foo.read for this and it seemed to solve the issue
if os.name == "nt": if len(foo) > 1 and foo.startswith(b"\x00"): foo = foo[1:] — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.
Fixed in master. thanks for submitting the fix!
I'm afraid this still doesn't work for me on Windows 11 Using r2 5.5.4
And I installed the latest from git:
pip install -e 'git+https://github.com/radareorg/radare2-r2pipe.git#egg=r2pipe&subdirectory=python'
With the above patch, but I still face the same problem, about 90% of the time the first cmd is empty, and the results don't come through unless I call r.cmd('')
afterwards
r2 5.5.4 is pretty old, like 1 year old. there was a release of the r2pipe module so no need to install it from git. i'll look into that if that's not the case.
Last release of r2pipe on PyPi is 1.6.5 from November 2021, and doesn't have the code from #147 ?
omg i forgot to publish 1.6.6 🤦 i just pushed 1.7.0 with some more changes. can you try again? thanks for the headsup
Thanks @trufae but it still doesn't work, what changes are you referring to?
Like I said I already tried commit https://github.com/radareorg/radare2-r2pipe/commit/e3b54c17e9812cbbdb3e84a4e96adf3c74b6b772 by downloading directly from git, but it still doesn't work unless I call r.cmd()
twice.
I'm currently just doing this in my code to work around it:
def double_call(r, cmd):
first = r.cmd(cmd)
return first if len(first) > 0 else r.cmd("")
i had some time (finally) to test and fix it. Please try again with r2pipe 1.7.1 :) it seems to work well on windows linux and mac now. i need to improve the testsuite.
i have also realized that if you have outdated plugins, the "please run r2pm .." message is breaking r2pipe too.
Still an issue for me, sadly:
I dont have windows 10, but on windows11 it works for me if i spawn python from inside r2. Like this:
cmd> radare2 -
[0x00000000]> #!pipe python
Python 3.10 ..
>>> import r2pipe
>>> r2 = r2pipe.open()
>>> r2.cmd("uname")
"Windows 10 Pro\n"
But it fails if i spawn r2 from the r2pipe instance.. so that means that i can repro, and it should be easy to fix. (hold my beer)
uhm .wtf why this thing works from a script but not from prompt?
Looks like a racist condition 🤔
Still an issue for me, sadly:
- python 3.11.2
- r2pipe 1.7.4
- radare2 5.8.2-w64
I also meet this problem on Windows10 and Windows11. It work well in shell. But in r2pipe, I cannot get result from first time use r2pipe.cmd(xx), only second time use r2pipe.cmd(''), I can get really result.
Fixed in r2pipe-1.8.0 please confirm :)
Environment
Description
There seems to be a bug here, the cmd command does not output the results correctly. This looks like an issue with newlines.
Test