Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Digest.file leaks fds on error #6775

Closed
vicuna opened this issue Feb 10, 2015 · 1 comment
Closed

Digest.file leaks fds on error #6775

vicuna opened this issue Feb 10, 2015 · 1 comment
Assignees
Milestone

Comments

@vicuna
Copy link

vicuna commented Feb 10, 2015

Original bug ID: 6775
Reporter: @sliquister
Assigned to: @gasche
Status: closed (set by @xavierleroy on 2016-12-07T10:47:13Z)
Resolution: fixed
Priority: normal
Severity: minor
Target version: 4.02.2+dev / +rc1
Fixed in version: 4.02.2+dev / +rc1
Category: standard library
Tags: patch
Monitored by: @hcarty

Bug description

$ for _i = 0 to 10000; do try ignore (Digest.file "." : string) with e -> Printf.printf "%s\n%!" (Printexc.to_string e); done;;
...
(Sys_error ".: Too many open files")
(Sys_error ".: Too many open files")
(Sys_error ".: Too many open files")

Digest.file should catch exceptions and close the channel, for instance:

let file filename =
let ic = open_in_bin filename in
let d =
try channel ic (-1)
with e -> close_in ic; raise e
in
close_in ic;
d

@vicuna
Copy link
Author

vicuna commented Feb 15, 2015

Comment author: @gasche

Fixed in 4.02 and trunk. Thanks!

@vicuna vicuna closed this as completed Dec 7, 2016
@vicuna vicuna added the stdlib label Mar 14, 2019
@vicuna vicuna added this to the 4.02.2 milestone Mar 14, 2019
@vicuna vicuna added the bug label Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants