Comments (6)
I don't think changing the struct format to big endian is the correct thing to do there. socket.inet_aton already returns network byte order, so adding the "!" to the struct unpack essentially flips it back.
I find it very strange that struct.unpack("L", '\x7f\x00\x00\x01') would throw "struct.error: unpack requires a string argument of length 8", since the format size for "L" is clearly defined as 4: http://docs.python.org/library/struct.html#format-characters
What does struct.calcsize("L") return?
As for the crash, UTP_SetCallbacks is a very simple function, so my only guess is that the utp_socket is not set or created properly. Can you provide a minimal example which reproduces the crash?
from libutp.
You can reproduce the first issue in Mac using this:
import socket
import struct
ip = '127.0.0.1'
size = struct.calcsize("L")
print "struct calcsize returns:"+str(size)
print "socket.inet_aton returns:"+str(len(socket.inet_aton(ip)))
The return size of the struct and of the socket.inet_aton will be 8 and 4 bytes respectively. No Match. I found out in a forum (http://code.activestate.com/recipes/66517-ip-address-conversion-functions-with-the-builtin-s/) that the interpretation via the struct-module is not correct on most platforms and consequently you have to force the format manually using "!L" instead of only "L".
Regarding the crash, I tried to debug a minimal python program that uses pyutp together with gdb for stepping through C++ libutp code. I found out that the program crashes when trying to access the UTP_Socket in the UTP_SetCallbacks function. It looks as if python provides a wrong pointer to the libutp C++ code in the latter.
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000002182160
0x00000001015e45a5 in UTP_SetCallbacks ()
I choose a stripped down version of WriteDataTestCase to reproduce the issue but any of the default tests where an actual connection is triggered should cause the error.
from libutp.
That forum post is referring to endianness. I believe the endianness is correct in libutp, it's the Python struct module size which is wrong. Looking closer at the Python struct documentation I linked to, I think this is a "native" vs. "standard" size problem. Try the format string "=L".
from libutp.
I tried the format string "=L" but this does not solve the crash I mentioned earlier. Can you reproduce the issue on your end?
from libutp.
Does "=L" solve the struct.error?
I do not have access to OS X at the moment since I have a PC. I'll see if I can borrow a Mac later this week.
from libutp.
As I mentioned in the previous post, the "=L" has not fixed the bug. Have you been able to reproduce the issue on a Mac machine?
from libutp.
Related Issues (20)
- Assertion `mtu_floor <= mtu_ceiling' failed. HOT 2
- reserved identifier violation
- Remove an unnecessary null pointer check HOT 1
- Compilation broken on Windows with `utp_shutdown` changes HOT 1
- utp_socket memory can be leaked
- ECN support
- uTP Fast Open
- How to distinguish whether other peers use utp or tcp protocol? HOT 1
- Client socket must send data first HOT 2
- Question about UTPSocket::cur_window_packets initialization. HOT 2
- How to just the package of utp ? HOT 2
- Unable to build on Haiku HOT 1
- Question: performance figures HOT 4
- Tag releases for downstream packaging
- Assertion `mtu_floor <= mtu_ceiling' failed
- how to identify utp HOT 4
- Is there any format spec for utp version 0?
- libutp in a multi-thread application
- Member access within misaligned address for type 'UTPSocketKeyData', which requires 8 byte alignment HOT 1
- fast_resend_seq_nr not initalize for utp client
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libutp.