Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005973OCamlOCaml standard librarypublic2013-04-03 10:402013-04-23 23:42
Assigned Toweis 
PlatformOSOS Version
Product Version4.00.1 
Target VersionFixed in Version 
Summary0005973: Format module incorrectly parses format string allowing to escape arguments
Description"@%s" format string when parsed by Format module breaks typing:
the @ escapes the following %s and the string argument won't be consumed at runtime, but the typer will still expect a string parameter.
Steps To Reproducelet _ = Format.(fprintf std_formatter "@%s%a" "" (fun _ _ -> ()) ())

Will execute "" as if it was a closure leading to unpredictable behavior, probably a segmentation fault.
TagsNo tags attached.
Attached Files

- Relationships
related to 0005380closedweis Strange sscanf input segfault 

-  Notes
gasche (developer)
2013-04-03 10:53

That seems strongly related to [^] . Do you have reproductibility information on which OCaml versions have the bug? Upto 4.00.1? Upto trunk?
def (reporter)
2013-04-03 11:20

Immediately reproducible with OCaml version 4.01.0+dev12-2013-03-28
gasche (developer)
2013-04-16 12:02

There is some exciting work by BenoƮt Vaugon in preparation, that may obviate those petty runtime format bugs.
weis (developer)
2013-04-23 20:54

Thank you for filling a bug report.

Bug 5380 has been fixed and closed. I will investigate and correct this one ASAP.
weis (developer)
2013-04-23 23:42

Fixed in trunk and in 4.00.2+dev1. Old obsolete @ escape behaviour was still implemented in module Format. Weird.

Two remarks to conclude:
1 Your Format invocation has no semantics, since there is no pretty-printing box opened in your format string before any printing conversion specification.
2 As specified in the documentation, @ characters should be escaped in format strings for the Format module, otherwise the @ character must introduce a valid pretty printing indication. You should then write %@ instead of @ and open a box before printing. For instance, "@[%@%s%a@]" is a valid format string and should work as expected.

- Issue History
Date Modified Username Field Change
2013-04-03 10:40 def New Issue
2013-04-03 10:52 gasche Relationship added related to 0005380
2013-04-03 10:53 gasche Note Added: 0009026
2013-04-03 11:20 def Note Added: 0009027
2013-04-16 12:02 gasche Note Added: 0009134
2013-04-16 12:02 gasche Status new => confirmed
2013-04-23 20:54 weis Note Added: 0009198
2013-04-23 20:54 weis Assigned To => weis
2013-04-23 20:54 weis Status confirmed => new
2013-04-23 23:42 weis Note Added: 0009199
2013-04-23 23:42 weis Status new => resolved
2013-04-23 23:42 weis Resolution open => fixed

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker