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

Issue with Scanf.Scanning.from_file #4119

Closed
vicuna opened this Issue Sep 21, 2006 · 2 comments

Comments

Projects
None yet
2 participants
@vicuna
Copy link
Collaborator

vicuna commented Sep 21, 2006

Original bug ID: 4119
Reporter: @xavierleroy
Assigned to: @pierreweis
Status: closed (set by @xavierleroy on 2007-02-21T14:49:18Z)
Resolution: fixed
Priority: normal
Severity: major
Version: 3.10+dev
Fixed in version: 3.10+dev
Category: ~DO NOT USE (was: OCaml general)

Bug description

(Reported on behalf of users at Athys.)

The following program dies with a Sys_error("Bad file descriptor") exception,
caused by reading from a closed in_channel.

------------- program --------------
open Printf

let _ =
let file = "toto" in
let scanbuf = Scanf.Scanning.from_file file in
let l = ref [] in
try
while not (Scanf.Scanning.end_of_input scanbuf) do
l := (Scanf.bscanf scanbuf " %S -> %S ; " (fun c d -> c,d))::!l
done
with
| Scanf.Scan_failure s -> failwith (sprintf "in file %s, %s" file s)
| End_of_file -> failwith (sprintf "in file %s, unexpected end of file" file)

---- input data file ./toto ----
"foo" -> "bar";

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Oct 4, 2006

Comment author: @pierreweis

Thanks for the bug report. This was due to interaction between mandatory closing of the input channel to the file and the end of file test condition.

The bug is corrected and a corresponding regression test has been added to the library test suite.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Oct 4, 2006

Comment author: @pierreweis

A regression test for this bug has been added.

@vicuna vicuna closed this Feb 21, 2007

@vicuna vicuna added the bug label Mar 19, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.