Also having read_debug, error_on_malformed and debug_always_treat_malformed as global mutable is not such a great idea in a concurrent world. These parameters should likely be made part of the Pdfio.input structure which I suspect you always have one under hand when you need to consult these parameters.
Per https://github.com/johnwhitington/camlpdf/issues/56#issuecomment-1510509751:
Also having read_debug, error_on_malformed and debug_always_treat_malformed as global mutable is not such a great idea in a concurrent world. These parameters should likely be made part of the Pdfio.input structure which I suspect you always have one under hand when you need to consult these parameters.