Problem opening connections on 64-bit machines #1

Closed
tymmothy opened this Issue Mar 14, 2012 · 2 comments

Comments

Projects
None yet
2 participants

HI,

I really appreciate the python-only VXI-11 implementation (especially after fighting for hours with assorted, broken, SWIG-based implementations).

I found an issue though with 64-bit machines...

Here's the traceback:

$ vxi11-cli ds1204b

Traceback (most recent call last):
File "/home/tymm/pyenvs/notebook/bin/vxi11-cli", line 9, in
load_entry_point('pyvxi11==0.3', 'console_scripts', 'vxi11-cli')()
File "/home/tymm/pyenvs/notebook/local/lib/python2.7/site-packages/pyvxi11-0.3-py2.7.egg/pyvxi11/vxi11_cli.py", line 60, in main
v.open()
File "/home/tymm/pyenvs/notebook/local/lib/python2.7/site-packages/pyvxi11-0.3-py2.7.egg/pyvxi11/vxi11.py", line 178, in open
self.vxi11_client.create_link(id(self), 0, 0, self.name)
File "/home/tymm/pyenvs/notebook/local/lib/python2.7/site-packages/pyvxi11-0.3-py2.7.egg/pyvxi11/vxi11.py", line 138, in create_link
self.unpacker.unpack_create_link_resp)
File "/home/tymm/pyenvs/notebook/local/lib/python2.7/site-packages/pyvxi11-0.3-py2.7.egg/pyvxi11/rpc.py", line 258, in make_call
pack_func(args)
File "/home/tymm/pyenvs/notebook/local/lib/python2.7/site-packages/pyvxi11-0.3-py2.7.egg/pyvxi11/vxi11.py", line 72, in pack_create_link_parms
self.pack_int(id)
File "/usr/lib/python2.7/xdrlib.py", line 57, in pack_int
self.__buf.write(struct.pack('>l', x))
struct.error: 'l' format requires -2147483648 <= number <= 2147483647

issue comes from interaction between code in Vxi11::open() and Vxi11Packer::pack_create_link_parms(), as the passed ID can exceed the value that can be stored in an int:

def open(self):
    log.info('Opening connection to %s', self.host)
    error, link_id, abort_port, max_recv_size = \
            self.vxi11_client.create_link(id(self), 0, 0, self.name)

...

def pack_create_link_parms(self, params):
    id, lock_device, lock_timeout, device = params

    self.pack_int(id)

I threw together a quick hack without digging too deeply into the code; it's flawed I'm sure, but gets things working for me for now -- just mask off the high bits of the id. I imagine this will come back to bite me at some point.

           self.vxi11_client.create_link(id(self) & 0x7fffffff, 0, 0, self.name)

If you have suggestions on a proper fix, would greatly appreciate it.

Thanks!

-Tymm

mwalle added a commit that referenced this issue Mar 15, 2012

bugfix: add posibility to specify own client_id
If no one was given, get it from the id of the Vxi11 object by taking the
lower 31 bits as client_id.

This fixes issues on 64bit hosts (#1). Thanks to Timothy Twillman.

Signed-off-by: Michael Walle <michael@walle.cc>
Owner

mwalle commented Mar 15, 2012

hopefully commit e2a2bb2 will fix this issue.

@mwalle mwalle closed this Mar 15, 2012

Seems to work great; thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment