Go-ipfs: --offline gets me to panic

Created on 14 Nov 2017  路  11Comments  路  Source: ipfs/go-ipfs

Version information: 0.4.11

Type: Bug

Severity: Critical

Description:

I just run

$ ipfs daemon --offline

and this is what happened

Initializing daemon...
Adjusting current ulimit to 2048...
Successfully raised file descriptor limit to 2048.
Swarm not listening, running in offline mode.
API server listening on /ip4/127.0.0.1/tcp/5001
Gateway (readonly) server listening on /ip4/127.0.0.1/tcp/8080
Daemon is ready

When I do a random request:

2017/11/14 11:46:53 http: panic serving 127.0.0.1:36519: runtime error: invalid memory address or nil pointer dereference
goroutine 103 [running]:
net/http.(*conn).serve.func1(0x1ab920c0)
    /usr/lib/go/src/net/http/server.go:1697 +0x9f
panic(0x87d1500, 0x8f2ef40)
    /usr/lib/go/src/runtime/panic.go:491 +0x1d0
github.com/ipfs/go-ipfs/core/corehttp.IPNSHostnameOption.func1.1(0x8e5e7e0, 0x1ab07aa8, 0x1b2b6380)
    /home/steb/projects/go/src/github.com/ipfs/distributions/dists/go-ipfs/gopath/src/github.com/ipfs/go-ipfs/core/corehttp/ipns_hostname.go:27 +0x15b
net/http.HandlerFunc.ServeHTTP(0x1ae9c800, 0x8e5e7e0, 0x1ab07aa8, 0x1b2b6380)
    /usr/lib/go/src/net/http/server.go:1918 +0x34
net/http.(*ServeMux).ServeHTTP(0x1b6fc320, 0x8e5e7e0, 0x1ab07aa8, 0x1b2b6380)
    /usr/lib/go/src/net/http/server.go:2254 +0xf0
net/http.(Handler).ServeHTTP-fm(0x8e5e7e0, 0x1ab07aa8, 0x1b2b6380)
    /usr/lib/go/src/net/http/h2_bundle.go:5462 +0x3b
gx/ipfs/QmX3QZ5jHEPidwUrymXV1iSCSUhdGxj15sm2gP4jKMef7B/client_golang/prometheus.InstrumentHandlerFuncWithOpts.func1(0x8e5f2e0, 0x1ae970e0, 0x1b2b6380)
    /home/steb/projects/go/src/github.com/ipfs/distributions/dists/go-ipfs/gopath/src/gx/ipfs/QmX3QZ5jHEPidwUrymXV1iSCSUhdGxj15sm2gP4jKMef7B/client_golang/prometheus/http.go:287 +0x1f5
net/http.HandlerFunc.ServeHTTP(0x1ab90030, 0x8e5f2e0, 0x1ae970e0, 0x1b2b6380)
    /usr/lib/go/src/net/http/server.go:1918 +0x34
net/http.(*ServeMux).ServeHTTP(0x1b6fc300, 0x8e5f2e0, 0x1ae970e0, 0x1b2b6380)
    /usr/lib/go/src/net/http/server.go:2254 +0xf0
net/http.serverHandler.ServeHTTP(0x1b2b6180, 0x8e5f2e0, 0x1ae970e0, 0x1b2b6380)
    /usr/lib/go/src/net/http/server.go:2619 +0x8e
net/http.(*conn).serve(0x1ab920c0, 0x8e5fe40, 0x1b6fcde0)
    /usr/lib/go/src/net/http/server.go:1801 +0x5d1
created by net/http.(*Server).Serve
    /usr/lib/go/src/net/http/server.go:2720 +0x1f6
2017/11/14 11:46:55 http: panic serving 127.0.0.1:36520: runtime error: invalid memory address or nil pointer dereference
goroutine 106 [running]:
net/http.(*conn).serve.func1(0x1aa6e6c0)
    /usr/lib/go/src/net/http/server.go:1697 +0x9f
panic(0x87d1500, 0x8f2ef40)
    /usr/lib/go/src/runtime/panic.go:491 +0x1d0
github.com/ipfs/go-ipfs/core/corehttp.IPNSHostnameOption.func1.1(0x8e5e7e0, 0x1aa0c780, 0x1b2b6280)
    /home/steb/projects/go/src/github.com/ipfs/distributions/dists/go-ipfs/gopath/src/github.com/ipfs/go-ipfs/core/corehttp/ipns_hostname.go:27 +0x15b
net/http.HandlerFunc.ServeHTTP(0x1ae9c800, 0x8e5e7e0, 0x1aa0c780, 0x1b2b6280)
    /usr/lib/go/src/net/http/server.go:1918 +0x34
net/http.(*ServeMux).ServeHTTP(0x1b6fc320, 0x8e5e7e0, 0x1aa0c780, 0x1b2b6280)
    /usr/lib/go/src/net/http/server.go:2254 +0xf0
net/http.(Handler).ServeHTTP-fm(0x8e5e7e0, 0x1aa0c780, 0x1b2b6280)
    /usr/lib/go/src/net/http/h2_bundle.go:5462 +0x3b
gx/ipfs/QmX3QZ5jHEPidwUrymXV1iSCSUhdGxj15sm2gP4jKMef7B/client_golang/prometheus.InstrumentHandlerFuncWithOpts.func1(0x8e5f2e0, 0x1aa702d0, 0x1b2b6280)
    /home/steb/projects/go/src/github.com/ipfs/distributions/dists/go-ipfs/gopath/src/gx/ipfs/QmX3QZ5jHEPidwUrymXV1iSCSUhdGxj15sm2gP4jKMef7B/client_golang/prometheus/http.go:287 +0x1f5
net/http.HandlerFunc.ServeHTTP(0x1ab90030, 0x8e5f2e0, 0x1aa702d0, 0x1b2b6280)
    /usr/lib/go/src/net/http/server.go:1918 +0x34
net/http.(*ServeMux).ServeHTTP(0x1b6fc300, 0x8e5f2e0, 0x1aa702d0, 0x1b2b6280)
    /usr/lib/go/src/net/http/server.go:2254 +0xf0
net/http.serverHandler.ServeHTTP(0x1b2b6180, 0x8e5f2e0, 0x1aa702d0, 0x1b2b6280)
    /usr/lib/go/src/net/http/server.go:2619 +0x8e
net/http.(*conn).serve(0x1aa6e6c0, 0x8e5fe40, 0x1b6fc160)
    /usr/lib/go/src/net/http/server.go:1801 +0x5d1
created by net/http.(*Server).Serve
    /usr/lib/go/src/net/http/server.go:2720 +0x1f6
2017/11/14 11:46:58 http: panic serving 127.0.0.1:36521: runtime error: invalid memory address or nil pointer dereference
goroutine 109 [running]:
net/http.(*conn).serve.func1(0x1aa6e960)
    /usr/lib/go/src/net/http/server.go:1697 +0x9f
panic(0x87d1500, 0x8f2ef40)
    /usr/lib/go/src/runtime/panic.go:491 +0x1d0
github.com/ipfs/go-ipfs/core/corehttp.IPNSHostnameOption.func1.1(0x8e5e7e0, 0x1aa0c810, 0x1b2b6400)
    /home/steb/projects/go/src/github.com/ipfs/distributions/dists/go-ipfs/gopath/src/github.com/ipfs/go-ipfs/core/corehttp/ipns_hostname.go:27 +0x15b
net/http.HandlerFunc.ServeHTTP(0x1ae9c800, 0x8e5e7e0, 0x1aa0c810, 0x1b2b6400)
    /usr/lib/go/src/net/http/server.go:1918 +0x34
net/http.(*ServeMux).ServeHTTP(0x1b6fc320, 0x8e5e7e0, 0x1aa0c810, 0x1b2b6400)
    /usr/lib/go/src/net/http/server.go:2254 +0xf0
net/http.(Handler).ServeHTTP-fm(0x8e5e7e0, 0x1aa0c810, 0x1b2b6400)
    /usr/lib/go/src/net/http/h2_bundle.go:5462 +0x3b
gx/ipfs/QmX3QZ5jHEPidwUrymXV1iSCSUhdGxj15sm2gP4jKMef7B/client_golang/prometheus.InstrumentHandlerFuncWithOpts.func1(0x8e5f2e0, 0x1aa70480, 0x1b2b6400)
    /home/steb/projects/go/src/github.com/ipfs/distributions/dists/go-ipfs/gopath/src/gx/ipfs/QmX3QZ5jHEPidwUrymXV1iSCSUhdGxj15sm2gP4jKMef7B/client_golang/prometheus/http.go:287 +0x1f5
net/http.HandlerFunc.ServeHTTP(0x1ab90030, 0x8e5f2e0, 0x1aa70480, 0x1b2b6400)
    /usr/lib/go/src/net/http/server.go:1918 +0x34
net/http.(*ServeMux).ServeHTTP(0x1b6fc300, 0x8e5f2e0, 0x1aa70480, 0x1b2b6400)
    /usr/lib/go/src/net/http/server.go:2254 +0xf0
net/http.serverHandler.ServeHTTP(0x1b2b6180, 0x8e5f2e0, 0x1aa70480, 0x1b2b6400)
    /usr/lib/go/src/net/http/server.go:2619 +0x8e
net/http.(*conn).serve(0x1aa6e960, 0x8e5fe40, 0x1b6fc980)
    /usr/lib/go/src/net/http/server.go:1801 +0x5d1
created by net/http.(*Server).Serve
    /usr/lib/go/src/net/http/server.go:2720 +0x1f6

I see a lot of /home/steb that's not me.. :/

kinbug

All 11 comments

That's me (I built this release).

@nicola what specific request did you make (gateway, commandline, ipns, ipfs, etc.)? I can't reproduce.

ipfs.nicola.io/ipfs/QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv/readme

Hm. That works for me... (well, not pulling from your server but I can read my own README).

I assume your using MacOS? I also take it you've modified the default config? Could you post a copy (or email it to me if it's sensitive). Could you try BACKING UP your current repo and config, creating a fresh one, and trying again (locally).

I have downloaded the linux version from the dist website and put it up on my Ubuntu 14 and run as it is.. :/
Will try doing that soon

I am also experiencing the same issue in only offline mode.
I just run ipfs daemon --offline after installing & initialization IPFS on azure.

It seems to be connected with metrics collector.

This is still happening 0.4.18, but I've managed to track it down a bit more. It looks like it happens when the Host: header in the request to the gateway is an FQDN with a real TLD, but only when the gateway is running in --offline mode. That is to say, these work (assuming your host is server.example.com):

curl http://localhost:8558/ipfs/Qm....
curl http://localhost.localdomain:8558/ipfs/Qm....
curl -H "Host: localhost:8558" http://server.example.com:8558/ipfs/Qm...
curl -H "Host: no.such.tld-exists:8558" http://server.example.com:8558/ipfs/Qm...

But these don't, in --offline mode:

curl -H "Host: server.example.com:8558" http://localhost:8558/ipfs/Qm....
curl -H "Host: no.such.domain.net:8558" http://localhost:8558/ipfs/Qm....
curl  http://server.example.com:8558/ipfs/Qm...

If you have it behind an nginx reverse proxy, you can work around this in the meantime by overriding Host: in the proxy configuration:

proxy_set_header        Host localhost:8558;

Thanks for this reproduction.

This has magically been fixed in 0.4.19. Not sure why...

@ToxicFrog can you confirm this?

Was this page helpful?
0 / 5 - 0 ratings