Skip to content

SIGSEGV in exchangeHTTPSClient #279

@mnordhoff

Description

@mnordhoff

I've been running 29e83b1 with HTTP/2 and HTTP/3 upstreams for a week. Then this happened:

$ ./dnsproxy --config-path=dnsproxy.yaml
Path: dnsproxy.yaml
2022/09/22 12:55:06 [info] Starting dnsproxy dev
2022/09/22 12:55:06 [info] Starting the DNS proxy server
2022/09/22 12:55:06 [info] DNS cache is enabled
2022/09/22 12:55:06 [info] MaxGoroutines is set to 1000
2022/09/22 12:55:06 [info] Creating the UDP server socket
2022/09/22 12:55:06 [info] Listening to udp://127.0.0.1:1053
2022/09/22 12:55:06 [info] Creating the UDP server socket
2022/09/22 12:55:06 [info] Listening to udp://[::1]:1053
2022/09/22 12:55:06 [info] Creating a TCP server socket
2022/09/22 12:55:06 [info] Listening to tcp://127.0.0.1:1053
2022/09/22 12:55:06 [info] Creating a TCP server socket
2022/09/22 12:55:06 [info] Listening to tcp://[::1]:1053
2022/09/22 12:55:06 [info] Entering the UDP listener loop on [::1]:1053
2022/09/22 12:55:06 [info] Entering the UDP listener loop on 127.0.0.1:1053
2022/09/22 12:55:06 [info] Entering the tcp listener loop on [::1]:1053
2022/09/22 12:55:06 [info] Entering the tcp listener loop on 127.0.0.1:1053
2022/09/22 12:55:33 failed to sufficiently increase receive buffer size (was: 208 kiB, wanted: 2048 kiB, got: 416 kiB). See https://github.com/lucas-clemente/quic-go/wiki/UDP-Receive-Buffer-Size for details.
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x7d90eb]

goroutine 462247 [running]:
github.com/AdguardTeam/dnsproxy/upstream.(*dnsOverHTTPS).exchangeHTTPSClient(0xc000022560, 0xc000186480, 0xc000186480?)
        /home/mnordhoff/src/git/dnsproxy/upstream/upstream_doh.go:161 +0x10b
github.com/AdguardTeam/dnsproxy/upstream.(*dnsOverHTTPS).exchangeHTTPS(0xc000022560, 0xa023c0?)
        /home/mnordhoff/src/git/dnsproxy/upstream/upstream_doh.go:144 +0xaa
github.com/AdguardTeam/dnsproxy/upstream.(*dnsOverHTTPS).Exchange(0xc000022560, 0xc000186480)
        /home/mnordhoff/src/git/dnsproxy/upstream/upstream_doh.go:123 +0x11b
github.com/AdguardTeam/dnsproxy/proxy.exchangeWithUpstream({0xa04860, 0xc000022560}, 0xc000186480)
        /home/mnordhoff/src/git/dnsproxy/proxy/exchange.go:68 +0x72
github.com/AdguardTeam/dnsproxy/proxy.(*Proxy).exchange(0xc000169880, 0xc000186480, {0xc00010d940?, 0xc000784100?, 0x1?})
        /home/mnordhoff/src/git/dnsproxy/proxy/exchange.go:39 +0x228
github.com/AdguardTeam/dnsproxy/proxy.(*Proxy).replyFromUpstream(0xc000169880, 0xc0000a0300)
        /home/mnordhoff/src/git/dnsproxy/proxy/proxy.go:388 +0x118
github.com/AdguardTeam/dnsproxy/proxy.(*Proxy).Resolve(0xc000169880, 0xc0000a0300)
        /home/mnordhoff/src/git/dnsproxy/proxy/proxy.go:471 +0xb4
github.com/AdguardTeam/dnsproxy/proxy.(*Proxy).handleDNSRequest(0xc000169880, 0xc0000a0300)
        /home/mnordhoff/src/git/dnsproxy/proxy/server.go:132 +0x3de
github.com/AdguardTeam/dnsproxy/proxy.(*Proxy).udpHandlePacket(0xc000169880, {0xc0007060c0, 0x22, 0x22}, {0xc0003f4090, 0x10, 0x10}, 0xc0008001b0, 0xc000012628)
        /home/mnordhoff/src/git/dnsproxy/proxy/server_udp.go:109 +0x2cb
github.com/AdguardTeam/dnsproxy/proxy.(*Proxy).udpPacketLoop.func1()
        /home/mnordhoff/src/git/dnsproxy/proxy/server_udp.go:76 +0x4f
created by github.com/AdguardTeam/dnsproxy/proxy.(*Proxy).udpPacketLoop
        /home/mnordhoff/src/git/dnsproxy/proxy/server_udp.go:75 +0x37e

The crash happened about when my Internet connectivity went down for a few minutes, so if there's a race condition when it's reconnecting, or when a connection is being torn down, it may have hit it.

I'm just guessing, but this may need to take the clientGuard lock?

if _, ok := p.client.Transport.(*http3.RoundTripper); ok {

dnsproxy.yaml

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions