Skip to content

Reader.open_ leaks its descriptor when trace header parsing fails #27

Description

@jeet-dekivadia

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    forwarded-to-js-devsThis report has been forwarded to Jane Street's internal review system.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions