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

panic: runtime error: slice bounds out of range [:-99] #159

Open
jehoshua7 opened this issue Jul 21, 2022 · 3 comments
Open

panic: runtime error: slice bounds out of range [:-99] #159

jehoshua7 opened this issue Jul 21, 2022 · 3 comments

Comments

@jehoshua7
Copy link

Version 1.0.0-1

The mobile phone was attached okay and transferring files. Then there were problems with navigating empty paths, and these messages

goroutine 6 [running]:
github.com/hanwen/go-mtpfs/mtp.(*Device).fetchPacket(0xc00012c280, 0xc000494000, 0x200, 0x200, 0xc000502070, 0x2000, 0x41b91e, 0x203000, 0xaa, 0x6c1578)
github.com/hanwen/go-mtpfs/mtp/mtp.go:231 +0x2a5
github.com/hanwen/go-mtpfs/mtp.(*Device).runTransaction(0xc00012c280, 0xc000151d80, 0xc000151cd0, 0x5c1940, 0xc000364000, 0x0, 0x0, 0x0, 0xc000151c48, 0x4114b8)
github.com/hanwen/go-mtpfs/mtp/mtp.go:345 +0x1e5
github.com/hanwen/go-mtpfs/mtp.(*Device).RunTransaction(0xc00012c280, 0xc000151d80, 0xc000151cd0, 0x5c1940, 0xc000364000, 0x0, 0x0, 0x0, 0xc000080000, 0x0)
github.com/hanwen/go-mtpfs/mtp/mtp.go:295 +0x97
github.com/hanwen/go-mtpfs/mtp.(*Device).GetData(0xc00012c280, 0xc000151d80, 0x566fe0, 0xc000492000, 0x18, 0x7f7f4148a7d0)
github.com/hanwen/go-mtpfs/mtp/ops.go:55 +0xac
github.com/hanwen/go-mtpfs/mtp.(*Device).GetStorageInfo(...)
github.com/hanwen/go-mtpfs/mtp/ops.go:149
github.com/hanwen/go-mtpfs/fs.(*mtpNodeImpl).Statfs(0xc0003046e0, 0x5c3d20, 0xc000216020, 0xc000090108, 0x0)
github.com/hanwen/go-mtpfs/fs/fs.go:240 +0xf7
github.com/hanwen/go-fuse/fs.(*rawBridge).StatFs(0xc00014c000, 0xc00008e000, 0xc000090198, 0xc000090108, 0xc000090198)
github.com/hanwen/go-fuse/fs/bridge.go:982 +0xfd
github.com/hanwen/go-fuse/fuse.doStatFs(0xc00012e160, 0xc000090000)
github.com/hanwen/go-fuse/fuse/opcode.go:427 +0x74
github.com/hanwen/go-fuse/fuse.(*Server).handleRequest(0xc00012e160, 0xc000090000, 0xc000000000)
github.com/hanwen/go-fuse/fuse/server.go:472 +0x2b6
github.com/hanwen/go-fuse/fuse.(*Server).loop(0xc00012e160, 0x0)
github.com/hanwen/go-fuse/fuse/server.go:445 +0x198
github.com/hanwen/go-fuse/fuse.(*Server).Serve(0xc00012e160)
github.com/hanwen/go-fuse/fuse/server.go:367 +0x45
created by github.com/hanwen/go-fuse/fs.Mount
github.com/hanwen/go-fuse/fs/mount.go:32 +0x105

@AdamMajer
Copy link

I see similar crashes with Samsung phone that makes it impossible to transfer files.

Switched to https://github.com/JasonFerrara/jmtpfs and it just worked

@hanwen
Copy link
Owner

hanwen commented Mar 19, 2023

	fetchPacketSize := d.fetchMaxPacketSize()
	data := make([]byte, fetchPacketSize)
	h := &usbBulkHeader{}
	rest, err := d.fetchPacket(data[:], h)
...

func (d *Device) fetchPacket(dest []byte, header *usbBulkHeader) (rest []byte, err error) {
	n, err := d.h.BulkTransfer(d.fetchEP, dest[:d.fetchMaxPacketSize()], d.Timeout)
	if n > 0 {

..


func (d *Device) fetchMaxPacketSize() int {
	return d.dev.GetMaxPacketSize(d.fetchEP)
}
...

func (d *Device) GetMaxPacketSize(endpoint byte) int {
	return int(C.libusb_get_max_packet_size(d.me(), C.uchar(endpoint)))
}

See https://sourcegraph.com/github.com/OneOfEleven/NanoVNA-App/-/blob/libusb.cpp?L772 , LIBUSB_ERROR_OTHER is -99.

@hanwen
Copy link
Owner

hanwen commented Mar 19, 2023

I assume there was some error before the crash that caused the USB connection to break before.

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

No branches or pull requests

3 participants