Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError: cannot use unpack() on <cdata 'char *' NULL> #104

Open
sdimovv opened this issue Apr 27, 2022 · 0 comments
Open

RuntimeError: cannot use unpack() on <cdata 'char *' NULL> #104

sdimovv opened this issue Apr 27, 2022 · 0 comments

Comments

@sdimovv
Copy link

sdimovv commented Apr 27, 2022

I believe I have encountered an edge case in pynng.

To reproduce:

  1. Start a Rep0 server serving on ipc:///tmp/my_socket.ipc
  2. Use nngcat:
nngcat --req0 --dial=${addr} --data=$(echo -n -e "\x00\x00\x00\x00") # addr=ipc:///tmp/my_socket.ipc

You should observe the following error:

Traceback (most recent call last):
  File "~/.pyenv/versions/3.7.12/lib/python3.7/threading.py", line 926, in _bootstrap_inner
    self.run()
  File "~/.pyenv/versions/3.7.12/lib/python3.7/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "~/path/to/dir/source_file.py", line 82, in listen
    request = self.rep_socket.recv()
  File "~/path/to/dir/.venv/lib/python3.7/site-packages/pynng/nng.py", line 455, in recv
    recvd = ffi.unpack(data[0], size_t[0])
RuntimeError: cannot use unpack() on <cdata 'char *' NULL>

I also tried serving the same request with nngcat like so:

nngcat --rep0 --bind-ipc=/tmp/my_socket.ipc --format=hex

Then, after running:

nngcat --req0 --dial=${addr} --data=$(echo -n -e "\x00\x00\x00\x00")

I get as output from the rep0 server:

""

If I change the req0 command to read the message body from file, like so:

nngcat --req0 --dial=${addr} --file=/tmp/my_msg_body --format=hex

It works with both nngcat and pynng, which leads me to believe that this is a bug.

Expected behaviour:

I would expect for pynng to either dismiss the request, return an error, or handle it like nngcat does.

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

No branches or pull requests

1 participant