Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006115OCamlOCaml typingpublic2013-08-02 14:272013-08-02 22:18
Reporteraguatto 
Assigned Togasche 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version4.00.1 
Target VersionFixed in Version 
Summary0006115: Unsound type checking of format strings for the Format module
DescriptionAccording to the Format documentation, when used in a format string
'@%' prints a '%' character. Thus, the following variable should be
of type 'unit' and print '%s' on the standard output. However, the
type checker thinks that %s is a format specifier:

# let f = Format.printf "@%s";;
val f : string -> unit = <fun>
# f "unused";;
%s- : unit = ()

This leads to segfault in more complex cases (see "Steps to reproduce").
Steps To Reproduce1. Run the ocaml toplevel
2. Enter the following code:

        OCaml version 4.00.1

# Format.printf "@%s%a" "unused" (fun fmt x -> Format.fprintf fmt "%d" x) 42;;
3. Witness segfault.
TagsNo tags attached.
Attached Files

- Relationships
related to 0005380closedweis Strange sscanf input segfault 

-  Notes
(0010083)
gasche (developer)
2013-08-02 19:25

This has been fixed in the development version:

# Format.printf "@%s%a" "unused" (fun fmt x -> Format.fprintf fmt "%d" x) 42;;
Exception:
Invalid_argument
 "Format.fprintf: bad format '@%s%a', giving up at character number 1 (%).".

It's still the kind of issues that a well-typed approach, as in PR#6017, would rule out statically.

- Issue History
Date Modified Username Field Change
2013-08-02 14:27 aguatto New Issue
2013-08-02 19:25 gasche Note Added: 0010083
2013-08-02 19:25 gasche Status new => resolved
2013-08-02 19:25 gasche Resolution open => fixed
2013-08-02 19:25 gasche Assigned To => gasche
2013-08-02 22:18 gasche Relationship added related to 0005380


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker