kitabisa / mubeng

An incredibly fast proxy checker & IP rotator with ease.
Apache License 2.0
1.52k stars 183 forks source link

Segfault - nil pointer dereference #237

Open aldanor opened 3 weeks ago

aldanor commented 3 weeks ago
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x7ed6b6]

goroutine 17231123 [running]:
ktbs.dev/mubeng/pkg/mubeng.(*Proxy).New(0xc0316e6f50, 0xc146b1c600)
        /root/mubeng/pkg/mubeng/mubeng.go:27 +0x156
ktbs.dev/mubeng/internal/server.(*Proxy).onRequest.func1(0xc146b1c600)
        /root/mubeng/internal/server/handler.go:63 +0x2cd
created by ktbs.dev/mubeng/internal/server.(*Proxy).onRequest
        /root/mubeng/internal/server/handler.go:44 +0x372

Unfortunately I'm not able to reproduce it directly but it already happened a few times (running on ubuntu, latest master version, go 1.20), after pushing a few hundred thousand requests through the proxy server at a rate of a few hundreds per second.

aldanor commented 3 weeks ago

Another one, not sure it's related but this time it logged an error right before a segfault

2024/06/03 21:12:36 [ERRO] ▶ [::1]:33684 parse "http://user:pass@12.34.567.89:12345\n": net/url: invalid control character in URL
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x7ed6b6]

goroutine 5356869 [running]:
ktbs.dev/mubeng/pkg/mubeng.(*Proxy).New(0xc03051cf50, 0xc009046600)
        /root/mubeng/pkg/mubeng/mubeng.go:27 +0x156
ktbs.dev/mubeng/internal/server.(*Proxy).onRequest.func1(0xc009046600)
        /root/mubeng/internal/server/handler.go:63 +0x2cd
created by ktbs.dev/mubeng/internal/server.(*Proxy).onRequest
        /root/mubeng/internal/server/handler.go:44 +0x372

I thought it's the last entry in the proxies file list but no, it's somewhere in the middle.

aldanor commented 3 weeks ago

Segfaulted again, this always seems to happen after lots of errors in the log like

2024/06/03 20:56:19 ERRO: [::1]:59244 context deadline exceeded (Client.Timeout or context cancellation while reading body)
2024/06/03 20:56:20 ERRO: [::1]:33454 unexpected EOF

and more parse errors (seems like some memory corruption going on somewhere? what's up with the last character in url strings?)

2024/06/03 20:50:27 ERRO: [::1]:37010 parse "http://user:pass@12.34.56.78:12345\x00": net/url: invalid control character in URL
2024/06/03 20:50:50 ERRO: [::1]:58162 parse "http://user:pass@12.34.56.78:12345i": invalid port ":60000w" after host
2024/06/03 20:57:54 ERRO: [::1]:56000 parse "http://user:pass@12.34.56.78:12345C": invalid port ":60000C" after host
dwisiswant0 commented 3 weeks ago

[...] what's up with the last character in url

It looks like your proxy file is corrupted— we don't append anything tho, and I don't think mubeng has any (missing, we should add it) validation.

aldanor commented 2 weeks ago

Nope, definitely not corrupted, double checked.