diffoscope.diff: Improve FIFO writing robustness.
We used to give input to diff using FIFO objects. fec9e97c changed this to avoid relying on /dev/fd, which is a good change for portability. Unfortunately, the implementation has a few issues of its own: * It feeds diff with normal files, rather than FIFOs. This could cause trouble if diff tries to read farther than the underlying feeder processes have written. * It uses threads to write to the pseudo-FIFO, but the file object is manipulated in multiple threads. I suspect this is the primary cause of the segfaults observed in #852013. * fd_from_feeder is decorated as a context manager, but it never yields anything, which is not how it's expected to be used. I'm not sure this is causing any problems, but it makes it harder to reason about what's going on. This commit introduces a new FIFOFeeder class. It is wholly responsible for creating and feeding the FIFO, so we don't have to pass file objects across the thread boundary and risk segfaults. It uses context management to tell when the FIFO is no longer needed, so it can clean up nicely. Signed-off-by: Chris Lamb <lamby@debian.org> Signed-off-by: Mattia Rizzolo <mattia@debian.org>
Loading
Please register or sign in to comment