LukeEmmet / duckling-proxy

Duckling proxy 🦆 is a Gemini proxy to access the Small Web
MIT License
34 stars 5 forks source link

runtime error: invalid memory address or nil pointer dereference #13

Open acidus99 opened 1 year ago

acidus99 commented 1 year ago

I run a public Duckling proxy. Duckling will crash, and I see the following in my logs. There are multiple instances of it, crashing Duckling and requiring me to restart it:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x11ae700]

goroutine 890 [running]:
net/url.(*URL).String(0x0)
    /usr/local/Cellar/go/1.18.3/libexec/src/net/url/url.go:800 +0x40
main.WebPipeHandler.Handle({}, {0x1?})
    /Users/x/go/pkg/mod/github.com/!luke!emmet/duckling-proxy@v0.0.0-20210723220542-e2bfd73a60d7/duckling-proxy.go:97 +0x56
github.com/makeworld-the-better-one/go-gemini.handleConnection({0x25dda58?, 0xc00007e000}, {0x13625a0, 0x1534c60})
    /Users/x/go/pkg/mod/github.com/makeworld-the-better-one/go-gemini@v0.8.5/server.go:97 +0xd4
created by github.com/makeworld-the-better-one/go-gemini.serve
    /Users/x/go/pkg/mod/github.com/makeworld-the-better-one/go-gemini@v0.8.5/server.go:82 +0xd5
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x11ae700]

goroutine 471 [running]:
net/url.(*URL).String(0x0)
    /usr/local/Cellar/go/1.18.3/libexec/src/net/url/url.go:800 +0x40
main.WebPipeHandler.Handle({}, {0x1?})
    /Users/x/go/pkg/mod/github.com/!luke!emmet/duckling-proxy@v0.0.0-20210723220542-e2bfd73a60d7/duckling-proxy.go:97 +0x56
github.com/makeworld-the-better-one/go-gemini.handleConnection({0x26a0198?, 0xc00007ee00}, {0x13625a0, 0x1534c60})
    /Users/x/go/pkg/mod/github.com/makeworld-the-better-one/go-gemini@v0.8.5/server.go:97 +0xd4
created by github.com/makeworld-the-better-one/go-gemini.serve
    /Users/x/go/pkg/mod/github.com/makeworld-the-better-one/go-gemini@v0.8.5/server.go:82 +0xd5
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x11ae700]

goroutine 3187 [running]:
net/url.(*URL).String(0x0)
    /usr/local/Cellar/go/1.18.3/libexec/src/net/url/url.go:800 +0x40
main.WebPipeHandler.Handle({}, {0x1?})
    /Users/x/go/pkg/mod/github.com/!luke!emmet/duckling-proxy@v0.0.0-20210723220542-e2bfd73a60d7/duckling-proxy.go:97 +0x56
github.com/makeworld-the-better-one/go-gemini.handleConnection({0x25dda58?, 0xc0002d8380}, {0x13625a0, 0x1534c60})
    /Users/x/go/pkg/mod/github.com/makeworld-the-better-one/go-gemini@v0.8.5/server.go:97 +0xd4
created by github.com/makeworld-the-better-one/go-gemini.serve
    /Users/x/go/pkg/mod/github.com/makeworld-the-better-one/go-gemini@v0.8.5/server.go:82 +0xd5
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x11ae700]

goroutine 6011 [running]:
net/url.(*URL).String(0x0)
    /usr/local/Cellar/go/1.18.3/libexec/src/net/url/url.go:800 +0x40
main.WebPipeHandler.Handle({}, {0x1?})
    /Users/x/go/pkg/mod/github.com/!luke!emmet/duckling-proxy@v0.0.0-20210723220542-e2bfd73a60d7/duckling-proxy.go:97 +0x56
github.com/makeworld-the-better-one/go-gemini.handleConnection({0x2ea0198?, 0xc00048d880}, {0x13625a0, 0x1534c60})
    /Users/x/go/pkg/mod/github.com/makeworld-the-better-one/go-gemini@v0.8.5/server.go:97 +0xd4
created by github.com/makeworld-the-better-one/go-gemini.serve
    /Users/x/go/pkg/mod/github.com/makeworld-the-better-one/go-gemini@v0.8.5/server.go:82 +0xd5
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x11ae700]

goroutine 368 [running]:
net/url.(*URL).String(0x0)
    /usr/local/Cellar/go/1.18.3/libexec/src/net/url/url.go:800 +0x40
main.WebPipeHandler.Handle({}, {0x1?})
    /Users/x/go/pkg/mod/github.com/!luke!emmet/duckling-proxy@v0.0.0-20210723220542-e2bfd73a60d7/duckling-proxy.go:97 +0x56
github.com/makeworld-the-better-one/go-gemini.handleConnection({0x6cdda18?, 0xc000072000}, {0x13625a0, 0x1534c60})
    /Users/x/go/pkg/mod/github.com/makeworld-the-better-one/go-gemini@v0.8.5/server.go:97 +0xd4
created by github.com/makeworld-the-better-one/go-gemini.serve
    /Users/x/go/pkg/mod/github.com/makeworld-the-better-one/go-gemini@v0.8.5/server.go:82 +0xd5
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x11ae700]

goroutine 3156 [running]:
net/url.(*URL).String(0x0)
    /usr/local/Cellar/go/1.18.3/libexec/src/net/url/url.go:800 +0x40
main.WebPipeHandler.Handle({}, {0x1?})
    /Users/x/go/pkg/mod/github.com/!luke!emmet/duckling-proxy@v0.0.0-20210723220542-e2bfd73a60d7/duckling-proxy.go:97 +0x56
github.com/makeworld-the-better-one/go-gemini.handleConnection({0x8ddda58?, 0xc00007e000}, {0x13625a0, 0x1534c60})
    /Users/x/go/pkg/mod/github.com/makeworld-the-better-one/go-gemini@v0.8.5/server.go:97 +0xd4
created by github.com/makeworld-the-better-one/go-gemini.serve
    /Users/x/go/pkg/mod/github.com/makeworld-the-better-one/go-gemini@v0.8.5/server.go:82 +0xd5

This appears in the log right after the line:

Info: Converting to text/gemini: [THE URL]

However I have restarted the service, and use the HTTP proxy again to visit that URL and it will work fine. So I'm not sure if that's related or not

LukeEmmet commented 1 year ago

thanks for the feedback - is there a specific URL that can reproduce the problem?

acidus99 commented 1 year ago

I'm running a public Duckling proxy that people use, so I only find out it's crashed once it stops working. I don't necessarily know the URL that crashed it.

Looking at the Duckling logs right before the crash I see:

Info: Converting to text/gemini: [URL]

However after restarting the service, if I attempt to access that URL again it works just fine. In short, I don't know if the URL in the logs has anything to do with the crash.

gzagatti commented 10 months ago

I've also faced this issue with Lagrange. When I accessed a proxied website, I would get a warning that the proxy server's certificate was not trusted which then crashed duckling-proxy. Once I trusted the certificate in Lagrange and re-started duckling-proxy everything worked without any issues.