Runtime error with cache remote and lsjson

I’m getting segmentation fault when trying to run lsjson on a cache remote. The first time I run lsjson the remote content is printed but any subsequent call to lsjson will result in SIGSEGV. No errors when I run ls or lsd. Tested rclone v1.42 and rclone v1.42-061-gbbda4ab1β on linux/amd64. Tested on v1.41 and it works properly.

2018/07/31 02:32:26 DEBUG : rclone: Version "v1.42" starting with parameters ["rclone" "lsjson" "drive-cache:" "-vv"]
2018/07/31 02:32:26 DEBUG : Using config file from "/home/.config/rclone/rclone.conf"
2018/07/31 02:32:26 DEBUG : drive-cache: wrapped gdrive:Videos at root 
2018/07/31 02:32:26 INFO  : drive-cache: Cache DB path: /home/.cache/rclone/cache-backend/drive-cache.db
2018/07/31 02:32:26 INFO  : drive-cache: Cache chunk path: /home/.cache/rclone/cache-backend/drive-cache
2018/07/31 02:32:26 INFO  : drive-cache: Chunk Memory: true
2018/07/31 02:32:26 INFO  : drive-cache: Chunk Size: 5M
2018/07/31 02:32:26 INFO  : drive-cache: Chunk Total Size: 5G
2018/07/31 02:32:26 INFO  : drive-cache: Chunk Clean Interval: 1m0s
2018/07/31 02:32:26 INFO  : drive-cache: Workers: 4
2018/07/31 02:32:26 INFO  : drive-cache: File Age: 6h0m0s
2018/07/31 02:32:26 DEBUG : Adding path "cache/expire" to remote control registry
2018/07/31 02:32:26 DEBUG : Adding path "cache/stats" to remote control registry
[
2018/07/31 02:32:26 DEBUG : Cache remote drive-cache:: list ''
2018/07/31 02:32:26 DEBUG : : list: warm 4 from cache for: , expiring on: 2018-07-31 08:25:18.068008691 -0600 MDT
2018/07/31 02:32:26 DEBUG : : list: cached entries: [Films Other TV Shows temp]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x557495d68fc4]

goroutine 63 [running]:
github.com/ncw/rclone/backend/cache.(*Directory).ID(0xc42022dab0, 0x557496948d00, 0xc42022dab0)
	<autogenerated>:1 +0x34
github.com/ncw/rclone/cmd/lsjson.glob..func1.1.1(0x0, 0x0, 0xc420700f00, 0x4, 0x4, 0x0, 0x0, 0x4, 0x0)
	/build/rclone/src/rclone-1.42/.gopath/src/github.com/ncw/rclone/cmd/lsjson/lsjson.go:147 +0x7b9
github.com/ncw/rclone/fs/walk.walk.func2(0xc4204e6f50, 0xc4204086c0, 0x557496938b80, 0x55749694dc80, 0xc420344dc0, 0x5574958c8f00, 0xc4204e6f70, 0xc420307f40, 0xc4204e6f60, 0xc4202c0e40, ...)
	/build/rclone/src/rclone-1.42/.gopath/src/github.com/ncw/rclone/fs/walk/walk.go:134 +0x291
created by github.com/ncw/rclone/fs/walk.walk
	/build/rclone/src/rclone-1.42/.gopath/src/github.com/ncw/rclone/fs/walk/walk.go:114 +0x265

Here’s my config file:

[gdrive]
type = drive
client_id = 
client_secret = 
token = {"access_token":"XXX","token_type":"Bearer","refresh_token":"YYY","expiry":"2018-07-31T03:25:17.148094023-06:00"}

[drive-cache]
type = cache
remote = gdrive:Videos
plex_url = 
plex_username = 
plex_password = 
chunk_size = 5M
info_age = 6h
chunk_total_size = 5G

Hmm, that is a bug!

Can you try this fix?

https://beta.rclone.org/branch/v1.42-063-g42d88be6-fix-cache-nil-dir/ (uploaded in 15-30 mins)

That seems to have fixed it. Thanks :slight_smile:

Thanks for testing :slight_smile: I’ve merged that fix to master.

https://beta.rclone.org/v1.42-067-gffd11662/ (uploaded in 15-30 mins)

It will be in the latest beta in 15-30 mins and in v1.43 :slight_smile: