oschwald / geoip2-golang

Unofficial MaxMind GeoIP2 Reader for Go
ISC License
1.86k stars 191 forks source link

Unexpected fault address opening MaxMind DB ISP file #73

Closed mzimmerman closed 3 years ago

mzimmerman commented 3 years ago

Opening file described at https://www.maxmind.com/en/geoip2-isp-database results in unexpected fault address.

`unexpected fault address 0x7f38fa135003 fatal error: fault [signal SIGBUS: bus error code=0x2 addr=0x7f38fa135003 pc=0x4e178c]

goroutine 1 [running]: runtime.throw(0x5156fd, 0x5) /usr/lib/go-1.16/src/runtime/panic.go:1117 +0x72 fp=0xc00014b860 sp=0xc00014b830 pc=0x435712 runtime.sigpanic() /usr/lib/go-1.16/src/runtime/signal_unix.go:731 +0x2c8 fp=0xc00014b898 sp=0xc00014b860 pc=0x44a368 github.com/oschwald/maxminddb-golang.nodeReader28.readLeft(...) /home/mezimm00/go/pkg/mod/github.com/oschwald/maxminddb-golang@v1.8.0/node.go:25 github.com/oschwald/maxminddb-golang.(*nodeReader28).readLeft(0xc0001280c0, 0x0, 0x50aea0)

:1 +0x4c fp=0xc00014b8b8 sp=0xc00014b898 pc=0x4e178c github.com/oschwald/maxminddb-golang.(*Reader).setIPv4Start(0xc000152180) /home/mezimm00/go/pkg/mod/github.com/oschwald/maxminddb-golang@v1.8.0/reader.go:121 +0x66 fp=0xc00014b8f0 sp=0xc00014b8b8 pc=0x4e0046 github.com/oschwald/maxminddb-golang.FromBytes(0x7f38fa135000, 0xaf4e18, 0xaf4e18, 0xaf4e18, 0xaf4e18, 0x0) /home/mezimm00/go/pkg/mod/github.com/oschwald/maxminddb-golang@v1.8.0/reader.go:106 +0x3be fp=0xc00014b9d0 sp=0xc00014b8f0 pc=0x4dfcbe github.com/oschwald/maxminddb-golang.Open(0x51c797, 0x27, 0x16, 0x1, 0x0) /home/mezimm00/go/pkg/mod/github.com/oschwald/maxminddb-golang@v1.8.0/reader_other.go:40 +0x27c fp=0xc00014ba80 sp=0xc00014b9d0 pc=0x4e0e1c github.com/oschwald/geoip2-golang.Open(0x51c797, 0x27, 0xc000118740, 0x0, 0x0) /home/mezimm00/go/pkg/mod/github.com/oschwald/geoip2-golang@v1.5.0/reader.go:252 +0x39 fp=0xc00014bae8 sp=0xc00014ba80 pc=0x4e1cb9`
oschwald commented 3 years ago

Thanks for the report. Would you be able to provide steps to reproduce? A SIGBUS would generally happen if the file was modified while it was open when using the memory-map mode.

mzimmerman commented 3 years ago

I get this error intermittently, and it is usually on the "Open" function call (one of the mmdb types) instead of on a "lookup" function. The mmdb files are on a samba based CEPH network share when I get the issue.

If I point to the CEPH mount directly (kernel mount), then there's no issue at all.

Copying the file locally seems not to reproduce the issue at all.

So I guess this has to do with a lack of SAMBA (on linux) being able to do mmap'd files correctly? Thanks for the help.

oschwald commented 3 years ago

Yes, I would guess this is related to the reliability of mmap on the mount. Besides copying it locally, you could also read the file into memory and use the FromBytes function to open it with the reader.

mzimmerman commented 3 years ago

True -- since these files aren't that big that worked just fine. Thanks for the help!