Trace.Reader.open_ opens a file descriptor and immediately passes it to make_reader:
let open_ ~filename = make_reader (Unix.openfile filename [ Unix.O_RDONLY ] 0)
make_reader parses the trace-info packet before returning the reader. A truncated or malformed trace can raise from that parsing path, and there is no reader value available for the caller to close. The descriptor opened by open_ is therefore leaked each time this happens. A process that inspects multiple bad traces can eventually exhaust its descriptor limit.
The success path needs to retain ownership exactly as it does today. On the exception path, open_ should close the descriptor best-effort and re-raise the original parsing exception. I have a focused patch ready for that cleanup.
Trace.Reader.open_opens a file descriptor and immediately passes it tomake_reader:make_readerparses the trace-info packet before returning the reader. A truncated or malformed trace can raise from that parsing path, and there is no reader value available for the caller to close. The descriptor opened byopen_is therefore leaked each time this happens. A process that inspects multiple bad traces can eventually exhaust its descriptor limit.The success path needs to retain ownership exactly as it does today. On the exception path,
open_should close the descriptor best-effort and re-raise the original parsing exception. I have a focused patch ready for that cleanup.