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

OverflowError: can't convert negative value to size_t #533

Closed
jwezel opened this issue Apr 19, 2014 · 12 comments · Fixed by #534
Closed

OverflowError: can't convert negative value to size_t #533

jwezel opened this issue Apr 19, 2014 · 12 comments · Fixed by #534

Comments

@jwezel
Copy link

jwezel commented Apr 19, 2014

When using the new master, send(_string)? with copy=False yields

Traceback (most recent call last):
  File "/home/j/Personal/Projects/virtualenv/unicom-server/bin/unicom", line 9, in <module>
    load_entry_point('unicom-server==0.1dev13', 'console_scripts', 'unicom')()
  File "/home/j/Personal/Projects/virtualenv/unicom-server/unicom/main.py", line 15, in Main
    app.Run()
  File "/home/j/Personal/Projects/virtualenv/unicom-server/unicom/app.py", line 44, in Run
    sess.run()
  File "/home/j/Personal/Projects/virtualenv/unicom-server/unicom/session.py", line 1325, in run
    self.send(client, 'REPLY', params, result[3], result[0])
  File "/home/j/Personal/Projects/virtualenv/unicom-server/unicom/session.py", line 1427, in send
    self.socket.send(client, zmq.SNDMORE, copy=False)
  File "socket.pyx", line 575, in zmq.backend.cython.socket.Socket.send (zmq/backend/cython/socket.c:5370)
  File "socket.pyx", line 629, in zmq.backend.cython.socket.Socket.send (zmq/backend/cython/socket.c:5218)                                                                                                                                   
  File "message.pyx", line 181, in zmq.backend.cython.message.Frame.__cinit__ (zmq/backend/cython/message.c:1676)                                                                                                                            
OverflowError: can't convert negative value to size_t                                                                                                                                                                                        ```

Same code works with copy=True
@minrk
Copy link
Member

minrk commented Apr 19, 2014

OS, Python version, Cython version, compiler, etc.? Can you provide a reproduction script?

@jwezel
Copy link
Author

jwezel commented Apr 20, 2014

Still the same configuration as in #531 (Memory leak (and other problems) with send_string() and recv_string()) but now with current master and basically the same scripts:

Server:

import zmq

cx = zmq.Context()
so = cx.socket(zmq.ROUTER)
so.bind('tcp://127.0.0.1:3333')
while True:
    p = so.recv()
    m = so.recv_unicode()

Client:

import zmq
import time

cx = zmq.Context()
so = cx.socket(zmq.DEALER)
so.connect('tcp://127.0.0.1:3333')
s = '**********************************************************'
for i in xrange(100000):
    so.send_unicode(s, copy=False)
    time.sleep(.0001)
so.close()
cx.term()
raw_input('Finished. ')

The client gets:

Traceback (most recent call last):
  File "c.py", line 9, in <module>
    so.send_unicode(s, copy=False)
  File "/home/j/Personal/Projects/virtualenv/unicom-server/lib/python2.7/site-packages/zmq/sugar/socket.py", line 319, in send_string
    return self.send(u.encode(encoding), flags=flags, copy=copy)
  File "socket.pyx", line 575, in zmq.backend.cython.socket.Socket.send (zmq/backend/cython/socket.c:5370)
  File "socket.pyx", line 629, in zmq.backend.cython.socket.Socket.send (zmq/backend/cython/socket.c:5218)
  File "message.pyx", line 181, in zmq.backend.cython.message.Frame.__cinit__ (zmq/backend/cython/message.c:1676)
OverflowError: can't convert negative value to size_t

Unit testing comes to my mind ...

@minrk
Copy link
Member

minrk commented Apr 20, 2014

Sorry, I don't see where you answered these before: What are your OS and Cython versions?

Your scripts do not produce an error on any of my machines with current master ( (Debian Ubuntu, OS X). Can you make sure you do a clean checkout and install of pyzmq? It may be that you have a partial upgrade of pyzmq.

Unit testing comes to my mind ...

Do the existing tests pass for you (nosetests zmq)? I would be a bit surprised if so. If they do pass, adding a failing test would be appreciated.

@jwezel
Copy link
Author

jwezel commented Apr 20, 2014

uname -a is

Linux shark.ocean 3.13.5-gentoo #3 SMP Sun Mar 30 03:19:35 CEST 2014 i686 Intel(R) Core(TM) i3 CPU M 330 @ 2.13GHz GenuineIntel GNU/Linux

Cython version is 0.20.1

I downloaded the current master package as a zip-file and installed it with pip. I had to upgrade Cython for that. The installation was successful.

The nosetests for zmq displayed a lot of those OverflowError: can't convert negative value to size_t errors.

@minrk
Copy link
Member

minrk commented Apr 20, 2014

What is sys.maxint?

@jwezel
Copy link
Author

jwezel commented Apr 20, 2014

2147483647

@minrk
Copy link
Member

minrk commented Apr 20, 2014

That's what I thought. I bet there is a bug that doesn't handle 32b properly. Now we are on the right track, at least. I'll make a 32b VM, and see if I can reproduce the error, then I can start figuring out what's wrong. Do you have access to a 64b machine? If so, can you confirm that you don't see the issue there?

@jwezel
Copy link
Author

jwezel commented Apr 20, 2014

Unfortunately not. I can only help you with 32-bit testing. This will still be around for a while ;)

@minrk
Copy link
Member

minrk commented Apr 20, 2014

I think I found it, can you test #534?

@minrk
Copy link
Member

minrk commented Apr 20, 2014

If you confirm that #534 fixes this issue, I can probably cut a 14.2 release tomorrow.

@jwezel
Copy link
Author

jwezel commented Apr 21, 2014

Yep, looks good now.

@minrk
Copy link
Member

minrk commented Apr 21, 2014

Thanks!

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

Successfully merging a pull request may close this issue.

2 participants