skynetservices/skynet-archive

skynet can't send non-small messages

Opened this issue · 4 comments

I believe I've found an issue that shows up when trying to send megabyte-scale messages in Skynet.

Skynet version: 2cf329f
Environment: OSX Lion 10.8.2 64-bit Intel
Go: go1.0.3

The minimum case is:

  1. create a service which accepts some payload containing an array of bytes
  2. create a client which makes an RPC call sending a payloads of around 6MB of binary data
  3. the service will receive and process the payload correctly, but a following message will be sent to the service with a bogus (and in most cases, gigabyte) packet size

I modified the bsoncoder.go file to print out the byte-shifted data length, and it is getting a phantom second message with an very large packet size:

skynet: 2013/02/02 20:42:21 trace: Service "Art" registered
BSON LENGTH = 5
req = &{ServiceMethod: Seq:0 next:<nil>}
BSON LENGTH = 49
BSON LENGTH = 6656246
req = &{ServiceMethod: Seq:0 next:<nil>}
skynet: 2013/02/02 20:42:26 trace: Method "Put" called with RequestInfo &{127.0.0.1:49159 127.0.0.1:49159 c96ea8d1-187d-4b87-9d40-9247e675cb20 0}
BSON LENGTH = 3242877185
panic: runtime error: makeslice: len out of range

The 6656246 value is the valid RPC call; the next BSON message being decoded is the spurious call. I also looked at the BSON length array; the 4th array element is 255 which gets left-bit-shifted by 24 bits and which creats this erroneous packet. I don't know where this message is coming from; the client is making a single RPC call.

I have a (possibly) minimum sample program, which I will attach to this ticket. Instructions for use:

  1. Create a binary data file called bigfile.bin; I did this with: dd if=/dev/random of=bigfile.bin bs=1024 count=6500
  2. Compile the client: go build -o client.bin ./client
  3. Compile the service: go build -o artd.bin ./artd
  4. Ensure that Skynet is up and running (on localhost)
  5. Start the service: ./artd.bin
  6. Execute the client: ./client.bin

The service will crash. So will the client, but that's because of a panic being thrown when the service connection errors out.

Source code for minimum case demonstrating the problem can be fetched from Google Drive: http://goo.gl/sorXf

I have verified the problem on a quad-core machine running Ubuntu Linux with the same code posted above. This is without my debugging changes to bsoncoders.go. I'm now sure that it's not a platform issue.

OS: Ubuntu 12.10 3.5.0-17-generic #28-Ubuntu SMP x86_64
CPU: Intel Q8200 (quad-core, 64-bit
Go: go1.0.2
Skynet: 2cf329f

skynet: 2013/02/05 19:36:45 trace: Service "Art" registered
skynet: 2013/02/05 19:36:53 trace: Method "Put" called with RequestInfo &{127.0.0.1:41675 127.0.0.1:41675 cdead888-8fea-4117-8e69-f572c531dcfd 0}
panic: runtime error: makeslice: len out of range

goroutine 20 [running]:
github.com/skynetservices/skynet/rpc/bsonrpc.(*Decoder).Decode(0xf8401276b0, 0x583be8, 0xf84010e2e0, 0x0, 0x0, ...)
        /usr/lib/go/src/pkg/github.com/skynetservices/skynet/rpc/bsonrpc/bsoncoders.go:56 +0x2b5
github.com/skynetservices/skynet/rpc/bsonrpc.(*scodec).ReadRequestHeader(0xf84010efc0, 0xf84010e2e0, 0x0, 0x0, 0x100000000, ...)
        /usr/lib/go/src/pkg/github.com/skynetservices/skynet/rpc/bsonrpc/server.go:25 +0x60
net/rpc.(*Server).readRequestHeader(0xf8400cb5a0, 0xf84010d4c0, 0xf84010efc0, 0x0, 0x0, ...)

Have you attempted to recreate this under Go 1.1?

I haven't but I will. Thanks.

Tested with go1.1.1. Appears to be working correctly, at least with the min_test.
Closing this ticket.