mirage/mirage-tcpip

Missing error paths in `write`

Closed this issue · 2 comments

pqwy commented

TCP, being a FLOW, has a write function whose type allows for signalling of errors.

But the actual implementation of write doesn't seem to attempt to do so.

Therefore, when a unikernel connects via TCP and starts writing, if the other end closes the connection, the write hangs indefinitely somewhere below Pcb.write_wait_for, even after the lower level decides to give up.

I also hit upon a memory leak with a unikernel that just keeps sending logs over TCP, but so far I failed to come up with a minimal case that reproduces this. I believe it's the hung writes keeping the buffer they've been given alive.

If you're not sure what's causing it, I'd suggest:

  • Modify the lowel level code to give up sooner (e.g. 1st time on 3rd packets).
  • Run with tracing on and compare what happens to the good vs bad threads.

This should be fixed by #150 and #148