Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0004119OCamlOCaml generalpublic2006-09-21 14:492007-02-21 15:49
Reporterxleroy 
Assigned Toweis 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version3.10+dev 
Target VersionFixed in Version3.10+dev 
Summary0004119: Issue with Scanf.Scanning.from_file
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";
--------------------------------

TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0003803)
weis (developer)
2006-10-04 12:10

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.
(0003804)
weis (developer)
2006-10-04 12:14

A regression test for this bug has been added.

- Issue History
Date Modified Username Field Change
2006-09-21 14:49 xleroy New Issue
2006-10-04 12:10 weis Note Added: 0003803
2006-10-04 12:14 weis Status new => resolved
2006-10-04 12:14 weis Fixed in Version => 3.10+dev
2006-10-04 12:14 weis Resolution open => fixed
2006-10-04 12:14 weis Assigned To => weis
2006-10-04 12:14 weis Note Added: 0003804
2007-02-21 15:49 xleroy Status resolved => closed


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker