nxtrace / NTrace-core

NextTrace, an open source visual route tracking CLI tool
https://www.nxtrace.org
GNU General Public License v3.0
5.76k stars 340 forks source link

[bugfix] fix inflightRequestLock deadlock in tcp/udp tracing #248

Closed FyZhu97 closed 3 months ago

FyZhu97 commented 3 months ago

take ipv4 tcp tracer as an example: In tracer/tcp_ipv4, TCPTracer.send() make a channel without buffer which is used to receive the result hop. image However, when send() is timeout, the func returns. So there will be no receivers to receive the channel, which causes the channel blocked forever. image

The result hop sended to the channel after timeout will block forever too. And the inflightRequestLock never unlocks, causing all the send() goroutines blocked forever and the waitgroup will never done. Then, deadlock. image

The same thing occurs in ipv6 tcp and udp tracer too.

This bugfix makes the channel with 1 buffer, which can avoid the send block.

FyZhu97 commented 3 months ago

new pull request on dev fork, close this