I am using lib/uplinkc for uploading object on storj V3 . for uploading object i am using following uplinkc functions
- upload
- upload_write
- upload_commit
my code is working fine on older version of uplinkc but when i have download/updated version of storj .i am getting following error while calling uplink_write function :
panic: runtime error: makeslice: len out of range [recovered]
panic: runtime error: makeslice: len out of range [recovered]
panic: runtime error: makeslice: len out of range [recovered]
panic: runtime error: makeslice: len out of range
goroutine 82 [running]:
gopkg.in/spacemonkeygo/monkit%2ev2.newSpan.func1(0xc00009c200)
/Users/qq/go/pkg/mod/gopkg.in/spacemonkeygo/monkit.v2@v2.0.0-20190623001553-09813957f0a8/ctx17.go:151 +0x375
panic(0x10661cb20, 0x1067b0f20)
/usr/local/go/src/runtime/panic.go:679 +0x1b2
gopkg.in/spacemonkeygo/monkit%2ev2.newSpan.func1(0xc00009c250)
/Users/qq/go/pkg/mod/gopkg.in/spacemonkeygo/monkit.v2@v2.0.0-20190623001553-09813957f0a8/ctx17.go:151 +0x375
panic(0x10661cb20, 0x1067b0f20)
/usr/local/go/src/runtime/panic.go:679 +0x1b2
gopkg.in/spacemonkeygo/monkit%2ev2.newSpan.func1(0xc000190020)
/Users/qq/go/pkg/mod/gopkg.in/spacemonkeygo/monkit.v2@v2.0.0-20190623001553-09813957f0a8/ctx17.go:151 +0x375
panic(0x10661cb20, 0x1067b0f20)
/usr/local/go/src/runtime/panic.go:679 +0x1b2
storj.io/uplink/storage/segments.(*PeekThresholdReader).IsLargerThan(0xc00018e330, 0xffffffffefbfea30, 0x20, 0x2, 0xc000034400)
/Users/qq/go/pkg/mod/storj.io/uplink@v0.0.0-20200109100422-69086b6ee4a8/storage/segments/peek.go:47 +0x68
storj.io/uplink/storage/streams.(*streamStore).upload(0xc0000cc730, 0x1067ccee0, 0xc000240140, 0xc0000a2060, 0xf, 0xc0000a2070, 0x1b, 0xc0000a2090, 0x2b, 0x30, ...)
/Users/qq/go/pkg/mod/storj.io/uplink@v0.0.0-20200109100422-69086b6ee4a8/storage/streams/store.go:176 +0x95a
storj.io/uplink/storage/streams.(*streamStore).Put(0xc0000cc730, 0x1067ccee0, 0xc0002400a0, 0xc0000a2060, 0xf, 0xc0000a2070, 0x1b, 0xc0000a2090, 0x2b, 0x30, ...)
/Users/qq/go/pkg/mod/storj.io/uplink@v0.0.0-20200109100422-69086b6ee4a8/storage/streams/store.go:92 +0x2c3
storj.io/uplink/storage/streams.(*shimStore).Put(0xc000128070, 0x1067ccee0, 0xc00021ea00, 0xc0000a2060, 0x2b, 0xc0000a2002, 0x1067bb780, 0xc0000100d0, 0x106c30358, 0x0, ...)
/Users/qq/go/pkg/mod/storj.io/uplink@v0.0.0-20200109100422-69086b6ee4a8/storage/streams/shim.go:49 +0x26e
storj.io/uplink/stream.NewUpload.func1(0xc004272f68, 0x0)
/Users/qq/go/pkg/mod/storj.io/uplink@v0.0.0-20200109100422-69086b6ee4a8/stream/upload.go:53 +0x2aa
golang.org/x/sync/errgroup.(*Group).Go.func1(0xc000192048, 0xc00017a280)
/Users/qq/go/pkg/mod/golang.org/x/sync@v0.0.0-20190911185100-cd5d95a43a6e/errgroup/errgroup.go:57 +0x64
created by golang.org/x/sync/errgroup.(*Group).Go
/Users/qq/go/pkg/mod/golang.org/x/sync@v0.0.0-20190911185100-cd5d95a43a6e/errgroup/errgroup.go:54 +0x66
I have added print statement in the go code to check. these are output of print statement :
Data on the 0x104469540 Upload write
Upload : &{{0xc00017a100 0x106088450} 0xc000192000}
Length : 18
Buf : [72 101 108 108 111 83 116 111 114 106 32 69 120 97 109 112 108 101]
Upload function
func upload_write(uploader C.UploaderRef, bytes *C.uint8_t, length C.size_t, cErr **C.char) C.size_t {
fmt.Println("Upload write ")
upload, ok := universe.Get(uploader._handle).(*Upload)
if !ok {
*cErr = C.CString("invalid uploader")
return C.size_t(0)
}
fmt.Println("Upload : ",upload)
ilength, ok := safeConvertToInt(length)
if !ok || ilength < 0 {
*cErr = C.CString("invalid length: too large or negative")
return C.size_t(0)
}
fmt.Println("Length : ",length)
if err := upload.ctx.Err(); err != nil {
if !errs2.IsCanceled(err) {
*cErr = C.CString(fmt.Sprintf("%+v", err))
}
return C.size_t(0)
}
buf := *(*[]byte)(unsafe.Pointer(
&reflect.SliceHeader{
Data: uintptr(unsafe.Pointer(bytes)),
Len: ilength,
Cap: ilength,
},
))
fmt.Println("Buf : ",buf)
n, err := upload.wc.Write(buf)
if err != nil {
if !errs2.IsCanceled(err) {
*cErr = C.CString(fmt.Sprintf("%+v", err))
}
}
fmt.Println("Returning size : ",n)
return C.size_t(n)
}