hanwen / go-fuse

FUSE bindings for Go
Other
2.03k stars 324 forks source link

panic: LARGEFILE (8000) overlaps with LARGEFILE (8000) #502

Closed ncw closed 7 months ago

ncw commented 8 months ago

When I compile and build this library for GOARCH=386 GOOS=linux I get this panic on startup

panic: LARGEFILE (8000) overlaps with LARGEFILE (8000)

goroutine 1 [running]:
github.com/hanwen/go-fuse/v2/fuse.(*flagNames).set(0xd219000, 0x8000, {0x9cdc4c6, 0x9})
    /home/ncw/go/pkg/mod/github.com/hanwen/go-fuse/v2@v2.4.3-0.20231120175208-cbb13ba8d29c/fuse/print.go:116 +0x25e
github.com/hanwen/go-fuse/v2/fuse.init.1()
    /home/ncw/go/pkg/mod/github.com/hanwen/go-fuse/v2@v2.4.3-0.20231120175208-cbb13ba8d29c/fuse/print_linux.go:14 +0x79

The panic is issued here

https://github.com/hanwen/go-fuse/blob/cbb13ba8d29c65dd5661be449c56563edcb7f5a1/fuse/print.go#L116

And this comes from this bit of init() code

https://github.com/hanwen/go-fuse/blob/cbb13ba8d29c65dd5661be449c56563edcb7f5a1/fuse/print_linux.go#L14

I think this is because the value is already set here

https://github.com/hanwen/go-fuse/blob/cbb13ba8d29c65dd5661be449c56563edcb7f5a1/fuse/print.go#L67

This is easy to replicate

$ GOOS=linux GOARCH=386 go build
$ ./fusebug 
panic: LARGEFILE (8000) overlaps with LARGEFILE (8000)

goroutine 1 [running]:
github.com/hanwen/go-fuse/v2/fuse.(*flagNames).set(0x90b3000, 0x8000, {0x811e6cf, 0x9})
    /home/ncw/go/pkg/mod/github.com/hanwen/go-fuse/v2@v2.4.3-0.20231120175208-cbb13ba8d29c/fuse/print.go:116 +0x240
github.com/hanwen/go-fuse/v2/fuse.init.1()
    /home/ncw/go/pkg/mod/github.com/hanwen/go-fuse/v2@v2.4.3-0.20231120175208-cbb13ba8d29c/fuse/print_linux.go:14 +0x79

with

package main

import (
    "fmt"

    _ "github.com/hanwen/go-fuse/v2/fuse"
)

func main() {
    fmt.Printf("Hello world!")
}

And

module fusebug

go 1.21.4

require github.com/hanwen/go-fuse/v2 v2.4.3-0.20231120175208-cbb13ba8d29c

require golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect

Note this does not replicate on linux/amd64.

On darwin/amd64 and darwin/arm64 it gives

panic: XTIMES (80000000) overlaps with INIT_RESERVED (80000000)

goroutine 1 [running]:
github.com/hanwen/go-fuse/v2/fuse.(*flagNames).set(0xc000313500?, 0x80000000, {0x104de4686?, 0x0?})
    /Users/runner/go/pkg/mod/github.com/hanwen/go-fuse/v2@v2.4.2/fuse/print.go:124 +0x15[9](https://github.com/rclone/rclone/actions/runs/7520820006/job/20470909802#step:11:10)
github.com/hanwen/go-fuse/v2/fuse.init.1()
    /Users/runner/go/pkg/mod/github.com/hanwen/go-fuse/v2@v2.4.2/fuse/print_darwin.go:[12](https://github.com/rclone/rclone/actions/runs/7520820006/job/20470909802#step:11:13) +0x2b
nileshpatra commented 8 months ago

Note this does not replicate on linux/amd64.

I confirm. On linux/amd64 the value of O_LARGEFILE is set to 0x0 so the code execution never reaches the panic since it is guarded by a

https://github.com/hanwen/go-fuse/blob/cbb13ba8d29c65dd5661be449c56563edcb7f5a1/fuse/print.go#L114

which ends up always evaluating to a 0 on 64 bit archs whenever we pass LARGEFILE flag. However on 32-bit and particularly i386, syscall.O_LARGEFILE actually evaluates to 0x8000 hence choking the code. It works fine on other 32-bit architectures where O_LARGEFILE value is different.

hanwen commented 7 months ago

https://github.com/hanwen/go-fuse/commit/e9e7c22af17af4611b5783a16458647088cc8dec